当前位置: 首页>>代码示例>>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;未经允许,请勿转载。