예제 #1
0
파일: ConnectTest.php 프로젝트: stunti/zf2
 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 (LDAP\Exception $zle) {
         $this->assertContains('Invalid credentials', $zle->getMessage());
     }
 }
예제 #2
0
파일: CanonTest.php 프로젝트: stunti/zf2
 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);
 }