• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Zend_Ldap_Attribute类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Zend_Ldap_Converter类代码示例发布时间:2022-05-23
下一篇:
PHP Zend_Ldap类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap