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


PHP Ldap::setOptions方法代码示例

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


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

示例1: testInvalidOptionResultsInException

 /**
  * @return void
  */
 public function testInvalidOptionResultsInException()
 {
     $optionName = 'invalid';
     try {
         $this->ldap->setOptions(array($optionName => 'irrelevant'));
         $this->fail('Expected Zend\\Ldap\\Exception\\LdapException not thrown');
     } catch (Exception\LdapException $e) {
         $this->assertEquals("Unknown Zend\\Ldap\\Ldap option: {$optionName}", $e->getMessage());
     }
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:13,代码来源:OfflineTest.php

示例2: authenticate

 /**
  * Authenticate a login request against ldap.
  * 
  * @return \Application\Model\Zend\Ldap\Exception\LdapException|boolean
  */
 public function authenticate()
 {
     $multiOptions = $this->getConfiguration();
     $ldap = new Ldap();
     foreach ($multiOptions as $options) {
         $ldap->setOptions($options);
         try {
             $ldap->bind($this->sFullIdentity, $this->sPass);
             $oResult = new Result(Result::SUCCESS, $this->sUser, array('Account is authenticate'));
             break;
         } catch (\Zend\Ldap\Exception\LdapException $oExp) {
             $oResult = new Result(Result::FAILURE_CREDENTIAL_INVALID, $this->sUser, array($oExp->getMessage()));
             $this->log('Could not authenticate user: ' . $this->sUser . ' reason is ' . $oExp->getMessage());
         }
     }
     return $oResult;
 }
开发者ID:Beanbiscuit,项目名称:examples,代码行数:22,代码来源:LdapAdapter.php

示例3: _prepareOptions

 /**
  * Sets the LDAP specific options on the Zend_Ldap instance
  *
  * @param  Zend_Ldap $ldap
  * @param  array $options
  * @return array of auth-adapter specific options
  */
 protected function _prepareOptions(\Zend\Ldap\Ldap $ldap, array $options)
 {
     $adapterOptions = array('group' => null, 'groupDn' => $ldap->getBaseDn(), 'groupScope' => \Zend\Ldap\Ldap::SEARCH_SCOPE_SUB, 'groupAttr' => 'cn', 'groupFilter' => 'objectClass=groupOfUniqueNames', 'memberAttr' => 'uniqueMember', 'memberIsDn' => true);
     foreach ($adapterOptions as $key => $value) {
         if (array_key_exists($key, $options)) {
             $value = $options[$key];
             unset($options[$key]);
             switch ($key) {
                 case 'groupScope':
                     $value = (int) $value;
                     if (in_array($value, array(\Zend\Ldap\Ldap::SEARCH_SCOPE_BASE, \Zend\Ldap\Ldap::SEARCH_SCOPE_ONE, \Zend\Ldap\Ldap::SEARCH_SCOPE_SUB), true)) {
                         $adapterOptions[$key] = $value;
                     }
                     break;
                 case 'memberIsDn':
                     $adapterOptions[$key] = $value === true || $value === '1' || strcasecmp($value, 'true') == 0;
                     break;
                 default:
                     $adapterOptions[$key] = trim($value);
                     break;
             }
         }
     }
     $ldap->setOptions($options);
     return $adapterOptions;
 }
开发者ID:navtis,项目名称:xerxes-pazpar2,代码行数:33,代码来源:Ldap.php

示例4: testSetOptionsConnect

 public function testSetOptionsConnect()
 {
     $ldap = new Ldap\Ldap();
     $ldap->setOptions($this->options);
     try {
         $ldap->connect()->bind('CN=ignored,DC=example,DC=com', 'ignored');
         $this->fail('Expected exception for invalid username');
     } catch (Exception\LdapException $zle) {
         $this->assertContains('Invalid credentials', $zle->getMessage());
     }
 }
开发者ID:rikaix,项目名称:zf2,代码行数:11,代码来源:ConnectTest.php

示例5: testAccountCanonization

 public function testAccountCanonization()
 {
     $options = $this->options;
     $ldap = new Ldap\Ldap($options);
     $canonDn = $ldap->getCanonicalAccountName(TESTS_ZEND_LDAP_ALT_USERNAME, Ldap\Ldap::ACCTNAME_FORM_DN);
     $this->assertEquals(TESTS_ZEND_LDAP_ALT_DN, $canonDn);
     $canonUsername = $ldap->getCanonicalAccountName(TESTS_ZEND_LDAP_ALT_USERNAME, Ldap\Ldap::ACCTNAME_FORM_USERNAME);
     $this->assertEquals(TESTS_ZEND_LDAP_ALT_USERNAME, $canonUsername);
     $canonBackslash = $ldap->getCanonicalAccountName(TESTS_ZEND_LDAP_ALT_USERNAME, Ldap\Ldap::ACCTNAME_FORM_BACKSLASH);
     $this->assertEquals(TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME_SHORT . '\\' . TESTS_ZEND_LDAP_ALT_USERNAME, $canonBackslash);
     $canonPrincipal = $ldap->getCanonicalAccountName(TESTS_ZEND_LDAP_ALT_USERNAME, Ldap\Ldap::ACCTNAME_FORM_PRINCIPAL);
     $this->assertEquals(TESTS_ZEND_LDAP_ALT_USERNAME . '@' . TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME, $canonPrincipal);
     $options['accountCanonicalForm'] = Ldap\Ldap::ACCTNAME_FORM_USERNAME;
     $ldap->setOptions($options);
     $canon = $ldap->getCanonicalAccountName(TESTS_ZEND_LDAP_ALT_USERNAME);
     $this->assertEquals(TESTS_ZEND_LDAP_ALT_USERNAME, $canon);
     $options['accountCanonicalForm'] = Ldap\Ldap::ACCTNAME_FORM_BACKSLASH;
     $ldap->setOptions($options);
     $canon = $ldap->getCanonicalAccountName(TESTS_ZEND_LDAP_ALT_USERNAME);
     $this->assertEquals(TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME_SHORT . '\\' . TESTS_ZEND_LDAP_ALT_USERNAME, $canon);
     $options['accountCanonicalForm'] = Ldap\Ldap::ACCTNAME_FORM_PRINCIPAL;
     $ldap->setOptions($options);
     $canon = $ldap->getCanonicalAccountName(TESTS_ZEND_LDAP_ALT_USERNAME);
     $this->assertEquals(TESTS_ZEND_LDAP_ALT_USERNAME . '@' . TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME, $canon);
     unset($options['accountCanonicalForm']);
     unset($options['accountDomainName']);
     $ldap->setOptions($options);
     $canon = $ldap->getCanonicalAccountName(TESTS_ZEND_LDAP_ALT_USERNAME);
     $this->assertEquals(TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME_SHORT . '\\' . TESTS_ZEND_LDAP_ALT_USERNAME, $canon);
     unset($options['accountDomainNameShort']);
     $ldap->setOptions($options);
     $canon = $ldap->getCanonicalAccountName(TESTS_ZEND_LDAP_ALT_USERNAME);
     $this->assertEquals(TESTS_ZEND_LDAP_ALT_USERNAME, $canon);
     $options['accountDomainName'] = TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME;
     $ldap->setOptions($options);
     $canon = $ldap->getCanonicalAccountName(TESTS_ZEND_LDAP_ALT_USERNAME);
     $this->assertEquals(TESTS_ZEND_LDAP_ALT_USERNAME . '@' . TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME, $canon);
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:38,代码来源:CanonTest.php


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