Exemple #1
0
 public function testSearch()
 {
     $connection = new \SlapOM\Connection(LDAP_HOST, LDAP_BIND_DN, LDAP_PASSWORD);
     $result = $connection->search('dc=knplabs,dc=com', '(objectClass=person)', array('cn'));
     $this->assert->array($result)->hasSize(2001);
     $connection = new \SlapOM\Connection('fakeHost', LDAP_BIND_DN, LDAP_PASSWORD);
     $this->assert->exception(function () use($connection) {
         $connection->search('dc=knplabs,dc=com', '(objectClass=person)', array('cn'));
     })->isInstanceOf('\\SlapOM\\Exception\\Ldap')->hasMessage('ERROR Could not bind to LDAP host=\'fakeHost:389\' with login=\'cn=root\'.. LDAP ERROR (-1) -- Can\'t contact LDAP server --. Can\'t contact LDAP server');
     $connection = new \SlapOM\Connection(LDAP_HOST, LDAP_BIND_DN, LDAP_PASSWORD);
     $this->assert->exception(function () use($connection) {
         $connection->search('dc=knplabs,dc=com', '(&=test)', array('cn'));
     })->isInstanceOf('\\SlapOM\\Exception\\Ldap')->hasMessage('ERROR Error while filtering dn \'dc=knplabs,dc=com\' with filter \'(&=test)\'.. LDAP ERROR (-7) -- Bad search filter --. Bad search filter');
 }