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


PHP Ldap\Ldap类代码示例

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


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

示例1: reload

 /**
  * Reload node attributes from LDAP.
  *
  * This is an online method.
  *
  * @param  \Zend\Ldap\Ldap $ldap
  * @return AbstractNode Provides a fluid interface
  */
 public function reload(Ldap\Ldap $ldap = null)
 {
     if ($ldap !== null) {
         $data = $ldap->getEntry($this->_getDn(), array('*', '+'), true);
         $this->loadData($data, true);
     }
     return $this;
 }
开发者ID:idwsdta,项目名称:INIT-frame,代码行数:16,代码来源:AbstractNode.php

示例2: testSearch

 public function testSearch()
 {
     $baseDn = 'ou=example,dc=org';
     $filter = '(&(uid=test_username))';
     $attributes = array('uid');
     $entry = array('dn' => 'uid=test_username,ou=example,dc=org', 'uid' => array('test_username'));
     $expect = array('count' => 1, $entry);
     $this->zend = $this->getMockBuilder('Zend\\Ldap\\Ldap')->getMock();
     $this->zendLdapDriver = new ZendLdapDriver($this->zend);
     $this->zend->expects($this->once())->method('searchEntries')->with($this->equalTo($filter), $this->equalTo($baseDn), $this->equalTo(Ldap::SEARCH_SCOPE_SUB), $this->equalTo($attributes))->will($this->returnValue(array($entry)));
     $this->assertEquals($expect, $this->zendLdapDriver->search($baseDn, $filter, $attributes));
 }
开发者ID:ancgate,项目名称:ldap_project,代码行数:12,代码来源:ZendLdapDriverTest.php

示例3: 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

示例4: create

 /**
  * Factory method to create the RootDse.
  *
  * @param \Zend\Ldap\Ldap $ldap
  * @return RootDse
  */
 public static function create(Ldap\Ldap $ldap)
 {
     $dn = Ldap\Dn::fromString('');
     $data = $ldap->getEntry($dn, ['*', '+'], true);
     if (isset($data['domainfunctionality'])) {
         return new RootDse\ActiveDirectory($dn, $data);
     } elseif (isset($data['dsaname'])) {
         return new RootDse\eDirectory($dn, $data);
     } elseif (isset($data['structuralobjectclass']) && $data['structuralobjectclass'][0] === 'OpenLDAProotDSE') {
         return new RootDse\OpenLdap($dn, $data);
     }
     return new static($dn, $data);
 }
开发者ID:GeeH,项目名称:zend-ldap,代码行数:19,代码来源:RootDse.php

示例5: create

 /**
  * Factory method to create the Schema node.
  *
  * @param  \Zend\Ldap\Ldap $ldap
  * @return \Zend\Ldap\Node\Schema
  * @throws \Zend\Ldap\Exception
  */
 public static function create(Ldap\Ldap $ldap)
 {
     $dn = $ldap->getRootDse()->getSchemaDn();
     $data = $ldap->getEntry($dn, array('*', '+'), true);
     switch ($ldap->getRootDse()->getServerType()) {
         case RootDSE::SERVER_TYPE_ACTIVEDIRECTORY:
             return new Schema\ActiveDirectory($dn, $data, $ldap);
         case RootDSE::SERVER_TYPE_OPENLDAP:
             return new Schema\OpenLdap($dn, $data, $ldap);
         case RootDSE::SERVER_TYPE_EDIRECTORY:
         default:
             return new self($dn, $data, $ldap);
     }
 }
开发者ID:rexmac,项目名称:zf2,代码行数:21,代码来源:Schema.php

示例6: 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

示例7: 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

示例8: 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

示例9: rewind

 /**
  * Rewind the Iterator to the first result item
  * Implements Iterator
  *
  * @throws \Zend\Ldap\Exception
  */
 public function rewind()
 {
     if (is_resource($this->_resultId)) {
         $this->_current = @ldap_first_entry($this->_ldap->getResource(), $this->_resultId);
         if ($this->_current === false && $this->_ldap->getLastErrorCode() > Ldap\Exception::LDAP_SUCCESS) {
             throw new Ldap\Exception($this->_ldap, 'getting first entry');
         }
     }
 }
开发者ID:rexmac,项目名称:zf2,代码行数:15,代码来源:DefaultIterator.php

示例10: testBindUserInterfaceByUsernameSuccessful

 public function testBindUserInterfaceByUsernameSuccessful()
 {
     $username = 'username';
     $password = 'password';
     $user = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserInterface');
     $user->expects($this->once())->method('getUsername')->will($this->returnValue($username));
     $this->zend->expects($this->once())->method('bind')->with($this->equalTo($username), $this->equalTo($password))->will($this->returnValue($this->zend));
     $this->assertTrue($this->zendLdapDriver->bind($user, $password));
 }
开发者ID:ancgate,项目名称:ldap_project,代码行数:9,代码来源:ZendLdapDriverMockedTest.php

示例11: rewind

 /**
  * Rewind the Iterator to the first result item
  * Implements Iterator
  *
  *
  * @throws \Zend\Ldap\Exception\LdapException
  */
 public function rewind()
 {
     if (is_resource($this->resultId)) {
         ErrorHandler::start();
         $this->current = ldap_first_entry($this->ldap->getResource(), $this->resultId);
         ErrorHandler::stop();
         if ($this->current === false && $this->ldap->getLastErrorCode() > Exception\LdapException::LDAP_SUCCESS) {
             throw new Exception\LdapException($this->ldap, 'getting first entry');
         }
     }
 }
开发者ID:haoyanfei,项目名称:zf2,代码行数:18,代码来源:DefaultIterator.php

示例12: find

 public function find($name, $value, $attr_name)
 {
     $this->bind();
     $filter = "{$attr_name}={$value}";
     $base_dn = $this->active_server['baseDn'];
     $this->log("Attempting to search for {$name}={$value} using basedn={$base_dn}");
     try {
         $hm = $this->ldap->search($filter, $base_dn, $this->scope);
         $this->log("Raw Ldap Object: " . var_export($hm, true), 7);
         if ($hm->count() == 0) {
             $this->log("Could not find an account for {$name}={$value}", 5);
             return false;
         } elseif ($hm->count() > 1) {
             $this->log("Found more than one user account for {$name}={$value}", 1);
             return false;
         }
         $this->user = $hm->current();
         $this->log("User entry response: " . var_export($this->user, true), 7);
         return $this->user;
     } catch (LdapException $exc) {
         return $exc->getMessage();
     }
 }
开发者ID:sha1,项目名称:zfcuser-ldap,代码行数:23,代码来源:AbstractAdapter.php

示例13: getAccountDn

 /**
  * Fix a bug, ex. CN=Alice Baker,CN=Users,DC=example,DC=com
  *
  * @param  string $acctname
  * @return string - Account DN
  */
 protected function getAccountDn($acctname)
 {
     $baseDn = $this->getBaseDn();
     if ($this->getBindRequiresDn() && isset($baseDn)) {
         try {
             return parent::getAccountDn($acctname);
         } catch (\Zend\Ldap\Exception\LdapException $zle) {
             if ($zle->getCode() != \Zend\Ldap\Exception\LdapException::LDAP_NO_SUCH_OBJECT) {
                 throw $zle;
             }
         }
         $acctname = $this->usernameAttribute . '=' . \Zend\Ldap\Filter\AbstractFilter::escapeValue($acctname) . ',' . $baseDn;
     }
     return parent::getAccountDn($acctname);
 }
开发者ID:chinazan,项目名称:zzcrm,代码行数:21,代码来源:LDAP.php

示例14: findUnit

 private function findUnit(Identity $identity)
 {
     if (null === $this->unit) {
         $filter = Filter::equals('mail', $identity->mail);
         $baseDn = Dn::factory($this->ldap->getBaseDn())->prepend(['ou' => 'people']);
         $result = $this->ldap->search($filter, $baseDn, Ldap::SEARCH_SCOPE_ONE, ['l']);
         if (1 !== $result->count()) {
             return;
         }
         $result = $result->current();
         $unitDn = $result['l'][0];
         $this->unit = $this->ldap->getNode($unitDn);
     }
     return $this->unit;
 }
开发者ID:eellak,项目名称:gredu_labs,代码行数:15,代码来源:CreateSchool.php

示例15: sort

 /**
  * Sort the iterator
  *
  * Sorting is done using the set sortFunction which is by default strnatcasecmp.
  *
  * The attribute is determined by lowercasing everything.
  *
  * The sort-value will be the first value of the attribute.
  *
  * @param string $sortAttribute The attribute to sort by. If not given the
  *                              value set via setSortAttribute is used.
  *
  * @return void
  */
 public function sort($sortAttribute)
 {
     foreach ($this->entries as $key => $entry) {
         $attributes = ldap_get_attributes($this->ldap->getResource(), $entry['resource']);
         $attributes = array_change_key_case($attributes, CASE_LOWER);
         if (isset($attributes[$sortAttribute][0])) {
             $this->entries[$key]['sortValue'] = $attributes[$sortAttribute][0];
         }
     }
     $sortFunction = $this->sortFunction;
     $sorted = usort($this->entries, function ($a, $b) use($sortFunction) {
         return $sortFunction($a['sortValue'], $b['sortValue']);
     });
     if (!$sorted) {
         throw new Exception\LdapException($this, 'sorting result-set');
     }
 }
开发者ID:zendframework,项目名称:zend-ldap,代码行数:31,代码来源:DefaultIterator.php


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