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


PHP Zend_Ldap::explodeDn方法代码示例

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


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

示例1: testExplodeDnOperation

 /**
  * @return void
  */
 public function testExplodeDnOperation()
 {
     $inputs = array('CN=Alice Baker,CN=Users,DC=example,DC=com' => true, 'CN=Baker\\, Alice,CN=Users,DC=example,DC=com' => true, 'OU=Sales,DC=local' => true, 'OU=Sales;DC=local' => true, 'OU=Sales ,DC=local' => true, 'OU=Sales, dC=local' => true, 'ou=Sales , DC=local' => true, 'OU=Sales ; dc=local' => true, 'DC=local' => true, ' DC=local' => true, 'DC= local  ' => true, 'username' => false, 'username@example.com' => false, 'EXAMPLE\\username' => false, 'CN=,Alice Baker,CN=Users,DC=example,DC=com' => false, 'CN=Users,DC==example,DC=com' => false, 'O=ACME' => true, '' => false, '   ' => false);
     foreach ($inputs as $dn => $expected) {
         $ret = Zend_Ldap::explodeDn($dn);
         $this->assertTrue($ret === $expected);
     }
 }
开发者ID:crodriguezn,项目名称:crossfit-milagro,代码行数:11,代码来源:OriginalOfflineTest.php

示例2: bind

 /**
  * @param string $username The username for authenticating the bind
  * @param string $password The password for authenticating the bind
  * @return Zend_Ldap Provides a fluent interface
  * @throws Zend_Ldap_Exception
  */
 public function bind($username = null, $password = null)
 {
     $moreCreds = true;
     if ($username === null) {
         $username = $this->_getUsername();
         $password = $this->_getPassword();
         $moreCreds = false;
     }
     if ($username === NULL) {
         /* Perform anonymous bind
          */
         $password = NULL;
     } else {
         /* Check to make sure the username is in DN form.
          */
         if (!Zend_Ldap::explodeDn($username)) {
             if ($this->_options['bindRequiresDn']) {
                 /* moreCreds stops an infinite loop if _getUsername does not
                  * return a DN and the bind requires it
                  */
                 if ($moreCreds) {
                     try {
                         $username = $this->_getAccountDn($username);
                     } catch (Zend_Ldap_Exception $zle) {
                         /**
                          * @todo Temporary measure to deal with exception thrown for ldap extension not loaded
                          */
                         if (strpos($zle->getMessage(), 'LDAP extension not loaded') !== false) {
                             throw $zle;
                         }
                         // end temporary measure
                         switch ($zle->getCode()) {
                             case Zend_Ldap_Exception::LDAP_NO_SUCH_OBJECT:
                             case Zend_Ldap_Exception::LDAP_X_DOMAIN_MISMATCH:
                                 throw $zle;
                         }
                         throw new Zend_Ldap_Exception(null, 'Failed to retrieve DN for account: ' . $zle->getMessage(), Zend_Ldap_Exception::LDAP_OPERATIONS_ERROR);
                     }
                 } else {
                     /**
                      * @see Zend_Ldap_Exception
                      */
                     require_once 'Zend/Ldap/Exception.php';
                     throw new Zend_Ldap_Exception(null, 'Binding requires username in DN form');
                 }
             } else {
                 $username = $this->getCanonicalAccountName($username, Zend_Ldap::ACCTNAME_FORM_PRINCIPAL);
             }
         }
     }
     if (!is_resource($this->_resource)) {
         $this->connect();
     }
     if ($username !== null && $password === '' && $this->_options['allowEmptyPassword'] !== true) {
         /**
          * @see Zend_Ldap_Exception
          */
         require_once 'Zend/Ldap/Exception.php';
         $zle = new Zend_Ldap_Exception(null, 'Empty password not allowed - see allowEmptyPassword option.');
     } else {
         if (@ldap_bind($this->_resource, $username, $password)) {
             return $this;
         }
         $message = $username === null ? $this->_connectString : $username;
         /**
          * @see Zend_Ldap_Exception
          */
         require_once 'Zend/Ldap/Exception.php';
         switch (Zend_Ldap_Exception::getLdapCode($this)) {
             case Zend_Ldap_Exception::LDAP_SERVER_DOWN:
                 /* If the error is related to establishing a connection rather than binding,
                  * the connect string is more informative than the username.
                  */
                 $message = $this->_connectString;
         }
         $zle = new Zend_Ldap_Exception($this->_resource, $message);
     }
     $this->disconnect();
     throw $zle;
 }
开发者ID:H38uS,项目名称:Impulsion,代码行数:86,代码来源:Ldap.php


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