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


PHP Zend_Ldap_Attribute類代碼示例

本文整理匯總了PHP中Zend_Ldap_Attribute的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Ldap_Attribute類的具體用法?PHP Zend_Ldap_Attribute怎麽用?PHP Zend_Ldap_Attribute使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: testChangePasswordWithUserAccountActiveDirectory

 public function testChangePasswordWithUserAccountActiveDirectory()
 {
     if ($this->_getLdap()->getRootDse()->getServerType() !== Zend_Ldap_Node_RootDse::SERVER_TYPE_ACTIVEDIRECTORY) {
         $this->markTestSkipped('Test can only be run on an ActiveDirectory server');
     }
     $options = $this->_getLdap()->getOptions();
     if ($options['useSsl'] !== true && $options['useStartTls'] !== true) {
         $this->markTestSkipped('Test can only be run on an SSL or TLS secured connection');
     }
     $dn = $this->_createDn('cn=New User,');
     $data = array();
     $password = 'pa$$w0rd';
     Zend_Ldap_Attribute::setAttribute($data, 'cn', 'New User', false);
     Zend_Ldap_Attribute::setAttribute($data, 'displayName', 'New User', false);
     Zend_Ldap_Attribute::setAttribute($data, 'sAMAccountName', 'newuser', false);
     Zend_Ldap_Attribute::setAttribute($data, 'userAccountControl', 512, false);
     Zend_Ldap_Attribute::setAttribute($data, 'objectClass', 'person', true);
     Zend_Ldap_Attribute::setAttribute($data, 'objectClass', 'organizationalPerson', true);
     Zend_Ldap_Attribute::setAttribute($data, 'objectClass', 'user', true);
     Zend_Ldap_Attribute::setPassword($data, $password, Zend_Ldap_Attribute::PASSWORD_UNICODEPWD, 'unicodePwd');
     try {
         $this->_getLdap()->add($dn, $data);
         $this->_getLdap()->bind($dn, $password);
         $newPasswd = 'newpasswd';
         $newData = array();
         Zend_Ldap_Attribute::setPassword($newData, $newPasswd, Zend_Ldap_Attribute::PASSWORD_UNICODEPWD);
         $this->_getLdap()->update($dn, $newData);
         try {
             $this->_getLdap()->bind($dn, $password);
             $this->fail('Expected exception not thrown');
         } catch (Zend_Ldap_Exception $zle) {
             $message = $zle->getMessage();
             $this->assertTrue(strstr($message, 'Invalid credentials') || strstr($message, 'Server is unwilling to perform'));
         }
         $this->assertType('Zend_Ldap', $this->_getLdap()->bind($dn, $newPasswd));
         $this->_getLdap()->bind();
         $this->_getLdap()->delete($dn);
     } catch (Zend_Ldap_Exception $e) {
         $this->_getLdap()->bind();
         if ($this->_getLdap()->exists($dn)) {
             $this->_getLdap()->delete($dn);
         }
         $this->fail($e->getMessage());
     }
 }
開發者ID:netvlies,項目名稱:zf,代碼行數:45,代碼來源:ChangePasswordTest.php

示例2: removeFromAttribute

 /**
  * Remove given values from a LDAP attribute
  *
  * @param  string      $attribName
  * @param  mixed|array $value
  * @return void
  */
 public function removeFromAttribute($attribName, $value)
 {
     Zend_Ldap_Attribute::removeFromAttribute($this->_currentData, $attribName, $value);
 }
開發者ID:netixx,項目名稱:Stock,代碼行數:11,代碼來源:Node.php

示例3: _parseLdapSchemaSyntax

 /**
  * Parse the given tokens into a data structure
  *
  * @param  array $data
  * @param  array $tokens
  * @return void
  */
 protected function _parseLdapSchemaSyntax(array &$data, array $tokens)
 {
     // tokens that have no value associated
     $noValue = array('single-value', 'obsolete', 'collective', 'no-user-modification', 'abstract', 'structural', 'auxiliary');
     // tokens that can have multiple values
     $multiValue = array('must', 'may', 'sup');
     while (count($tokens) > 0) {
         $token = strtolower(array_shift($tokens));
         if (in_array($token, $noValue)) {
             $data[$token] = true;
             // single value token
         } else {
             $data[$token] = array_shift($tokens);
             // this one follows a string or a list if it is multivalued
             if ($data[$token] == '(') {
                 // this creates the list of values and cycles through the tokens
                 // until the end of the list is reached ')'
                 $data[$token] = array();
                 while ($tmp = array_shift($tokens)) {
                     if ($tmp == ')') {
                         break;
                     }
                     if ($tmp != '$') {
                         $data[$token][] = Zend_Ldap_Attribute::convertFromLdapValue($tmp);
                     }
                 }
             } else {
                 $data[$token] = Zend_Ldap_Attribute::convertFromLdapValue($data[$token]);
             }
             // create a array if the value should be multivalued but was not
             if (in_array($token, $multiValue) && !is_array($data[$token])) {
                 $data[$token] = array($data[$token]);
             }
         }
     }
 }
開發者ID:GerDner,項目名稱:luck-docker,代碼行數:43,代碼來源:OpenLdap.php

示例4: testPasswordGenerationUnicodePwd

 public function testPasswordGenerationUnicodePwd()
 {
     $password = 'new';
     $unicodePwd = Zend_Ldap_Attribute::createPassword($password, Zend_Ldap_Attribute::PASSWORD_UNICODEPWD);
     $this->assertEquals(10, strlen($unicodePwd));
     $this->assertEquals("\"new\"", $unicodePwd);
 }
開發者ID:travisj,項目名稱:zf,代碼行數:7,代碼來源:AttributeTest.php

示例5: _changePassLdap

 protected function _changePassLdap(\Core_Dto_Mapping $dtoPass, $userEntity, $recover = FALSE)
 {
     try {
         $ldapUser = $userEntity->getSqPessoa()->getSqPessoaFisica()->getNuCpf();
         $userPasswd = $dtoPass->getTxSenha();
         $adminAuth = $this->_adminAuthLDAP();
         if (!$recover) {
             $adminAuth->bind($ldapUser, $userPasswd);
         }
         $userDn = current($adminAuth->search("samAccountName={$ldapUser}")->toArray());
         if (!$userDn) {
             throw new \Core_Exception_ServiceLayer_Verification("Usuário inexistente no LDAP");
         }
         $userData = array();
         \Zend_Ldap_Attribute::setPassword($userData, $dtoPass->getTxSenhaNova(), \Zend_Ldap_Attribute::PASSWORD_UNICODEPWD);
         $this->_adminAuthLDAP()->update($userDn['dn'], $userData);
     } catch (\Zend_Ldap_Exception $exc) {
         $message = sprintf('[SICA-e] LDAP Error in %s: "%s"', __METHOD__, $exc->getMessage());
         error_log($message);
         $this->getMessaging()->addErrorMessage($exc->getMessage());
         $message = sprintf('[Erro no LDAP] %s', $exc->getMessage());
         $ldapCode = $exc->getCode();
         if ($ldapCode > 0) {
             $message = sprintf('LDAP0x%x', $ldapCode);
         }
         throw new \Core_Exception_ServiceLayer_Verification($message);
     }
 }
開發者ID:sgdoc,項目名稱:sgdoce-codigo,代碼行數:28,代碼來源:Usuario.php

示例6: updateByLogin

 public function updateByLogin($login, $options)
 {
     $filter = Zend_Ldap_Filter::equals('samaccountname', $login);
     $ldap = $this->getLdap();
     $users = $ldap->search($filter);
     if ($users->count() > 0) {
         $user = $users->getFirst();
         $dn = $user['dn'];
         $entry = array();
         foreach ($options as $attrib => $value) {
             Zend_Ldap_Attribute::setAttribute($entry, $attrib, $value);
         }
         $res = $ldap->update($dn, $entry);
         return $res;
     }
     return false;
 }
開發者ID:dafik,項目名稱:dfi,代碼行數:17,代碼來源:AD.php

示例7: _setLDAPAttribute

 /**
  * Sets the value for the given LDAP attribute.
  * 
  * @param array  $entry      LDAP entry
  * @param string $attribName Attribute name.
  * @param mixed  $value      Value.
  */
 protected function _setLDAPAttribute(&$entry, $attribName, $value)
 {
     $attribName = strtolower($attribName);
     Zend_Ldap_Attribute::setAttribute($entry, $attribName, $value);
 }
開發者ID:RKathees,項目名稱:is-connectors,代碼行數:12,代碼來源:Ldap.php


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