예제 #1
0
 public function testLdapQueryScopeOneLevel()
 {
     $ldap = new Adapter($this->getLdapConfig());
     $ldap->getConnection()->bind('cn=admin,dc=symfony,dc=com', 'symfony');
     $one_level_result = $ldap->createQuery('ou=Components,dc=symfony,dc=com', '(objectclass=*)', array('scope' => Query::SCOPE_ONE))->execute();
     $subtree_count = $ldap->createQuery('ou=Components,dc=symfony,dc=com', '(objectclass=*)')->execute()->count();
     $this->assertNotEquals($one_level_result->count(), $subtree_count);
     $this->assertEquals($one_level_result->count(), 1);
     $this->assertEquals($one_level_result[0]->getAttribute('ou'), array('Ldap'));
 }
예제 #2
0
 /**
  * @group functional
  */
 public function testLdapQuery()
 {
     $ldap = new Adapter($this->getLdapConfig());
     $ldap->getConnection()->bind('cn=admin,dc=symfony,dc=com', 'symfony');
     $query = $ldap->createQuery('dc=symfony,dc=com', '(&(objectclass=person)(ou=Maintainers))', array());
     $result = $query->execute();
     $this->assertInstanceOf(Collection::class, $result);
     $this->assertCount(1, $result);
     $entry = $result[0];
     $this->assertInstanceOf(Entry::class, $entry);
     $this->assertEquals(array('Fabien Potencier'), $entry->getAttribute('cn'));
     $this->assertEquals(array('*****@*****.**', '*****@*****.**'), $entry->getAttribute('mail'));
 }
예제 #3
0
 /**
  * @return Collection|Entry[]
  */
 private function executeSearchQuery($expectedResults = 1)
 {
     $results = $this->adapter->createQuery('dc=symfony,dc=com', '(objectclass=person)')->execute();
     $this->assertCount($expectedResults, $results);
     return $results;
 }