當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Ldap::connect方法代碼示例

本文整理匯總了PHP中Ldap::connect方法的典型用法代碼示例。如果您正苦於以下問題:PHP Ldap::connect方法的具體用法?PHP Ldap::connect怎麽用?PHP Ldap::connect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Ldap的用法示例。


在下文中一共展示了Ldap::connect方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testFailedSearch

 public function testFailedSearch()
 {
     if ($this->skipIfNoLdap()) {
         return;
     }
     $mock = $this->getMock('Bart\\PHPLDAP');
     $mock->expects($this->exactly(2))->method('ldap_bind')->will($this->returnValueMap(array(array('conn', 'binduser', 'bindpw', true), array('conn', $this->brayDN, 'jbraynardpwd', false))));
     $this->stubSearchSequence($mock);
     Diesel::registerInstantiator('Bart\\PHPLDAP', function () use($mock) {
         return $mock;
     });
     $ldap = new Ldap($this->config);
     $ldap->connect();
     $this->assertThrows('\\Bart\\LdapException', "LDAP Auth: failure, username/password did not match for {$this->brayDN}", function () use($mock, $ldap) {
         $ldap->auth_user('jbraynard', 'jbraynardpwd');
     });
 }
開發者ID:martinsv,項目名稱:bart,代碼行數:17,代碼來源:LdapTest.php

示例2:

<?php

/**
 * Setup the test accounts on the ldap server.
 *
 * Assumes the username entries are 'uid'.
 * Note that all tests will crash horribly if any new trilogy characters are introduced here ;)
 *
 * @copyright Copyright (C) 1999-2013 eZ Systems AS. All rights reserved.
 * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
 * @version //autogentag//
 * @package tests
 */
$dc = "dc=phpuc,dc=ez,dc=no";
$host = "phpuc.ez.no";
$connection = Ldap::connect("ldap://{$host}", "cn=%s,{$dc}", 'admin', 'wee123');
Ldap::delete($connection, 'yoda', "ou=StarWars,{$dc}");
Ldap::delete($connection, 'boba.fett', "ou=StarWars,{$dc}");
Ldap::delete($connection, 'obi.wan', "ou=StarWars,{$dc}");
Ldap::delete($connection, 'jabba.thehutt', "ou=StarWars,{$dc}");
Ldap::delete($connection, 'darth.vader', "ou=StarWars,{$dc}");
Ldap::delete($connection, 'leia', "ou=StarWars,{$dc}");
Ldap::delete($connection, 'han.solo', "ou=StarWars,{$dc}");
Ldap::delete($connection, 'chewbacca', "ou=StarWars,{$dc}");
Ldap::deleteGroup($connection, 'Jedi', "ou=RebelAlliance,ou=StarWars,{$dc}");
Ldap::deleteGroup($connection, 'RebelAlliance', "ou=StarWars,{$dc}");
Ldap::deleteGroup($connection, 'Sith', "ou=GalacticEmpire,ou=StarWars,{$dc}");
Ldap::deleteGroup($connection, 'GalacticEmpire', "ou=StarWars,{$dc}");
Ldap::deleteGroup($connection, 'Rogues', "ou=StarWars,{$dc}");
Ldap::deleteGroup($connection, 'StarWars', $dc);
Ldap::addGroup($connection, 'StarWars', $dc);
開發者ID:nfrp,項目名稱:ezpublish,代碼行數:31,代碼來源:setup_accounts.php

示例3: crypt

<?php

/**
 * Setup the test accounts on the ldap server.
 *
 * Assumes the username entries are 'uid'.
 *
 */
$dc = "dc=foo,dc=bar";
$connection = Ldap::connect('ldap://localhost', "cn=%s,{$dc}", 'admin', 'wee123');
Ldap::delete($connection, 'john.doe', $dc);
Ldap::delete($connection, 'jan.modaal', $dc);
Ldap::delete($connection, 'zhang.san', $dc);
Ldap::delete($connection, 'hans.mustermann', $dc);
Ldap::delete($connection, 'Ruşinică Piţigoi', $dc);
Ldap::add($connection, 'john.doe', '{CRYPT}' . crypt('foobar'), $dc);
Ldap::add($connection, 'jan.modaal', '{SHA}' . base64_encode(pack('H*', sha1('qwerty'))), $dc);
Ldap::add($connection, 'zhang.san', '{MD5}' . base64_encode(pack('H*', md5('asdfgh'))), $dc);
//Ldap::add( $connection, 'jan.modaal', '{SHA}' . base64_encode( sha1( 'qwerty' ) ), $dc );
//Ldap::add( $connection, 'zhang.san', '{MD5}' . base64_encode( md5( 'asdfgh' ) ), $dc );
Ldap::add($connection, 'hans.mustermann', 'abcdef', $dc);
Ldap::add($connection, 'Ruşinică Piţigoi', '12345', $dc);
Ldap::fetchAll($connection, $dc);
Ldap::close($connection);
/**
 * Support for LDAP functions connect, add, delete and get_entries.
 */
class Ldap
{
    /**
     * Connects to an LDAP server specified by $uri, with admin $user and $password.
開發者ID:jacomyma,項目名稱:GEXF-Atlas,代碼行數:31,代碼來源:setup_accounts.php


注:本文中的Ldap::connect方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。