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


PHP Zend_Ldap_Attribute::setPassword方法代码示例

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


在下文中一共展示了Zend_Ldap_Attribute::setPassword方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: testPasswordSettingCustomAttribute

 public function testPasswordSettingCustomAttribute()
 {
     $data = array();
     Zend_Ldap_Attribute::setPassword($data, 'pa$$w0rd', Zend_Ldap_Attribute::PASSWORD_HASH_SHA, 'myAttribute');
     $password = Zend_Ldap_Attribute::getAttribute($data, 'myAttribute', 0);
     $this->assertNotNull($password);
 }
开发者ID:travisj,项目名称:zf,代码行数:7,代码来源:AttributeTest.php

示例3: setPasswordAttribute

 /**
  * Sets a LDAP password.
  *
  * @param  string $password
  * @param  string $hashType
  * @param  string $attribName
  * @return Zend_Ldap_Node Provides a fluid interface
  * @throws Zend_Ldap_Exception
  */
 public function setPasswordAttribute($password, $hashType = Zend_Ldap_Attribute::PASSWORD_HASH_MD5, $attribName = 'userPassword')
 {
     $this->_assertChangeableAttribute($attribName);
     Zend_Ldap_Attribute::setPassword($this->_currentData, $password, $hashType, $attribName);
     return $this;
 }
开发者ID:netixx,项目名称:Stock,代码行数:15,代码来源:Node.php

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


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