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


PHP Zend_Ldap_Dn::checkDn方法代碼示例

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


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

示例1: isValid

 /**
  * Defined by Zend_Validate_Interface.
  *
  * Returns true if and only if $value is a valid DN.
  *
  * @param string $value The value to be validated.
  * 
  * @return boolean
  */
 public function isValid($value)
 {
     $valid = Zend_Ldap_Dn::checkDn($value);
     if ($valid === false) {
         $this->_error(self::MALFORMED);
         return false;
     }
     return true;
 }
開發者ID:Gradven,項目名稱:what3.1.7,代碼行數:18,代碼來源:Dn.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 (empty($username)) {
         /* Perform anonymous bind
          */
         $username = null;
         $password = null;
     } else {
         /* Check to make sure the username is in DN form.
          */
         /**
          * @see Zend_Ldap_Dn
          */
         #require_once 'Zend/Ldap/Dn.php';
         if (!Zend_Ldap_Dn::checkDn($username)) {
             if ($this->_getBindRequiresDn()) {
                 /* 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) {
                         switch ($zle->getCode()) {
                             case Zend_Ldap_Exception::LDAP_NO_SUCH_OBJECT:
                             case Zend_Ldap_Exception::LDAP_X_DOMAIN_MISMATCH:
                             case Zend_Ldap_Exception::LDAP_X_EXTENSION_NOT_LOADED:
                                 throw $zle;
                         }
                         throw new Zend_Ldap_Exception(null, 'Failed to retrieve DN for account: ' . $username . ' [' . $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, $this->_getAccountCanonicalForm());
             }
         }
     }
     if (!is_resource($this->_resource)) {
         $this->connect();
     }
     if ($username !== null && $password === '' && $this->_getAllowEmptyPassword() !== 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)) {
             $this->_boundUser = $username;
             return $this;
         }
         $message = $username === null ? $this->_connectString : $username;
         /**
          * @see Zend_Ldap_Exception
          */
         #require_once 'Zend/Ldap/Exception.php';
         switch ($this->getLastErrorCode()) {
             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, $message);
     }
     $this->disconnect();
     throw $zle;
 }
開發者ID:jpbender,項目名稱:mage_virtual,代碼行數:86,代碼來源:Ldap.php

示例3: testCoreExplodeDnWithMultiValuedRdn

 public function testCoreExplodeDnWithMultiValuedRdn()
 {
     $dn = 'cn=name1+uid=user,cn=name2,dc=example,dc=org';
     $k = array();
     $v = array();
     $this->assertTrue(Zend_Ldap_Dn::checkDn($dn, $k, $v));
     $ke = array(array('cn', 'uid'), 'cn', 'dc', 'dc');
     $ve = array(array('name1', 'user'), 'name2', 'example', 'org');
     $this->assertEquals($ke, $k);
     $this->assertEquals($ve, $v);
     $dn = 'cn=name11+cn=name12,cn=name2,dc=example,dc=org';
     $this->assertFalse(Zend_Ldap_Dn::checkDn($dn));
     $dn = 'CN=name11+Cn=name12,cn=name2,dc=example,dc=org';
     $this->assertFalse(Zend_Ldap_Dn::checkDn($dn));
 }
開發者ID:sasezaki,項目名稱:mirror-zf1-tests,代碼行數:15,代碼來源:ExplodingTest.php


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