当前位置: 首页>>代码示例>>PHP>>正文


PHP Ldap::bind方法代码示例

本文整理汇总了PHP中Zend\Ldap\Ldap::bind方法的典型用法代码示例。如果您正苦于以下问题:PHP Ldap::bind方法的具体用法?PHP Ldap::bind怎么用?PHP Ldap::bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Ldap\Ldap的用法示例。


在下文中一共展示了Ldap::bind方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 protected function setUp()
 {
     if (!constant('TESTS_ZEND_LDAP_ONLINE_ENABLED')) {
         $this->markTestSkipped("Zend_Ldap online tests are not enabled");
     }
     $options = array('host' => TESTS_ZEND_LDAP_HOST, 'username' => TESTS_ZEND_LDAP_USERNAME, 'password' => TESTS_ZEND_LDAP_PASSWORD, 'baseDn' => TESTS_ZEND_LDAP_WRITEABLE_SUBTREE);
     if (defined('TESTS_ZEND_LDAP_PORT') && TESTS_ZEND_LDAP_PORT != 389) {
         $options['port'] = TESTS_ZEND_LDAP_PORT;
     }
     if (defined('TESTS_ZEND_LDAP_USE_START_TLS')) {
         $options['useStartTls'] = TESTS_ZEND_LDAP_USE_START_TLS;
     }
     if (defined('TESTS_ZEND_LDAP_USE_SSL')) {
         $options['useSsl'] = TESTS_ZEND_LDAP_USE_SSL;
     }
     if (defined('TESTS_ZEND_LDAP_BIND_REQUIRES_DN')) {
         $options['bindRequiresDn'] = TESTS_ZEND_LDAP_BIND_REQUIRES_DN;
     }
     if (defined('TESTS_ZEND_LDAP_ACCOUNT_FILTER_FORMAT')) {
         $options['accountFilterFormat'] = TESTS_ZEND_LDAP_ACCOUNT_FILTER_FORMAT;
     }
     if (defined('TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME')) {
         $options['accountDomainName'] = TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME;
     }
     if (defined('TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME_SHORT')) {
         $options['accountDomainNameShort'] = TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME_SHORT;
     }
     $this->ldap = new Ldap\Ldap($options);
     $this->ldap->bind();
 }
开发者ID:razvansividra,项目名称:pnlzf2-1,代码行数:30,代码来源:AbstractOnlineTestCase.php

示例2: bind

 /**
  * {@inheritDoc}
  */
 public function bind(UserInterface $user, $password)
 {
     if ($user instanceof LdapUserInterface && $user->getDn()) {
         $bind_rdn = $user->getDn();
     } else {
         $bind_rdn = $user->getUsername();
     }
     try {
         $this->logDebug(sprintf('ldap_bind(%s, ****)', $bind_rdn));
         $bind = $this->driver->bind($bind_rdn, $password);
         return $bind instanceof Ldap;
     } catch (ZendLdapException $exception) {
         $this->zendExceptionHandler($exception);
     }
     return false;
 }
开发者ID:Mapaxe,项目名称:FR3DLdapBundle,代码行数:19,代码来源:ZendLdapDriver.php

示例3: getLdap

 /**
  * Returns Zend LDAP
  *
  * @return \Zend\Ldap\Ldap
  */
 public function getLdap()
 {
     if ($this->_ldap === null) {
         $options = array('host' => Yii::$app->getModule('user')->settings->get('auth.ldap.hostname'), 'port' => Yii::$app->getModule('user')->settings->get('auth.ldap.port'), 'username' => Yii::$app->getModule('user')->settings->get('auth.ldap.username'), 'password' => Yii::$app->getModule('user')->settings->get('auth.ldap.password'), 'useStartTls' => Yii::$app->getModule('user')->settings->get('auth.ldap.encryption') == 'tls', 'useSsl' => Yii::$app->getModule('user')->settings->get('auth.ldap.encryption') == 'ssl', 'bindRequiresDn' => true, 'baseDn' => Yii::$app->getModule('user')->settings->get('auth.ldap.baseDn'), 'accountFilterFormat' => Yii::$app->getModule('user')->settings->get('auth.ldap.loginFilter'));
         $this->_ldap = new \Zend\Ldap\Ldap($options);
         $this->_ldap->bind();
     }
     return $this->_ldap;
 }
开发者ID:VasileGabriel,项目名称:humhub,代码行数:14,代码来源:ZendLdapClient.php

示例4: bind

 public function bind()
 {
     $options = $this->config;
     /* We will try to loop through the list of servers
      * if no active servers are available then we will use the error msg
      */
     foreach ($options as $server) {
         $this->log("Attempting bind with ldap");
         try {
             $this->ldap = new ZendLdap($server);
             $this->ldap->bind();
             $this->log("Bind successful setting active server.");
             $this->active_server = $server;
         } catch (LdapException $exc) {
             $this->error[] = $exc->getMessage();
             continue;
         }
     }
 }
开发者ID:sha1,项目名称:zfcuser-ldap,代码行数:19,代码来源:AbstractAdapter.php

示例5: factory_ldap

 public function factory_ldap(ServiceManager $sm)
 {
     $config = $sm->get('Config');
     $ldapConfig = $config['ldap'];
     try {
         $ldap = new Ldap($ldapConfig);
         $ldap->bind($ldapConfig['username'], $ldapConfig['password']);
     } catch (LdapException $e) {
         Debug::dump($e->getMessage());
         die;
     }
     return $ldap;
 }
开发者ID:notquitehere,项目名称:gibson,代码行数:13,代码来源:Module.php

示例6: authenticate

 /**
  * Authenticate a login request against ldap.
  * 
  * @return \Application\Model\Zend\Ldap\Exception\LdapException|boolean
  */
 public function authenticate()
 {
     $multiOptions = $this->getConfiguration();
     $ldap = new Ldap();
     foreach ($multiOptions as $options) {
         $ldap->setOptions($options);
         try {
             $ldap->bind($this->sFullIdentity, $this->sPass);
             $oResult = new Result(Result::SUCCESS, $this->sUser, array('Account is authenticate'));
             break;
         } catch (\Zend\Ldap\Exception\LdapException $oExp) {
             $oResult = new Result(Result::FAILURE_CREDENTIAL_INVALID, $this->sUser, array($oExp->getMessage()));
             $this->log('Could not authenticate user: ' . $this->sUser . ' reason is ' . $oExp->getMessage());
         }
     }
     return $oResult;
 }
开发者ID:Beanbiscuit,项目名称:examples,代码行数:22,代码来源:LdapAdapter.php

示例7: testMismatchDomainBind

 public function testMismatchDomainBind()
 {
     $ldap = new Ldap\Ldap($this->options);
     try {
         $ldap->bind('BOGUS\\doesntmatter', 'doesntmatter');
         $this->fail('Expected exception not thrown');
     } catch (Exception\LdapException $zle) {
         $this->assertTrue($zle->getCode() == Exception\LdapException::LDAP_X_DOMAIN_MISMATCH);
     }
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:10,代码来源:CanonTest.php

示例8: testBoundUserIsReturnedAfterBinding

 /**
  * @group ZF-8259
  */
 public function testBoundUserIsReturnedAfterBinding()
 {
     $ldap = new Ldap\Ldap($this->_options);
     $ldap->bind();
     $this->assertEquals(TESTS_ZEND_LDAP_USERNAME, $ldap->getBoundUser());
 }
开发者ID:heiglandreas,项目名称:zf2,代码行数:9,代码来源:BindTest.php

示例9: getComputers

 public function getComputers($computerService)
 {
     $domain = $this->options['accountDomainName'];
     $ldap = new Ldap($this->options);
     $ldap->bind();
     $result = $ldap->search('(&(objectCategory=computer))', 'dc=wr,dc=local', Ldap::SEARCH_SCOPE_SUB);
     foreach ($result as $item) {
         if ($item['name'][0] != '') {
             $hostname = $item['name'][0];
             $computer = $computerService->findByDNSName($hostname, $domain);
             if (!$computer) {
                 $computer = new Computer();
                 $computerService->setType($computer, 'Computer');
                 $computerService->setStatus($computer, 'In Use');
                 $computerService->setManufacturer($computer, 'Dell');
                 $computer->setHostname($hostname)->setDomain($domain);
             }
             // Operating system
             if (array_key_exists('operatingsystem', $item)) {
                 $computer->setOsName($item['operatingsystem'][0]);
             }
             // Operating system service pack
             if (array_key_exists('operatingsystemservicepack', $item)) {
                 $computer->setOsServicePack($item['operatingsystemservicepack'][0]);
             }
             // Operating system version.
             if (array_key_exists('operatingsystemversion', $item)) {
                 $computer->setOsVersion($item['operatingsystemversion'][0]);
             }
             //  die(var_dump($computer->getStatus()));
             $computerService->persist($computer);
         }
     }
 }
开发者ID:srayner,项目名称:cobalt,代码行数:34,代码来源:ActiveDirectory.php


注:本文中的Zend\Ldap\Ldap::bind方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。