Ejemplo n.º 1
0
 /**
  * Tests setting search frees memory
  *
  * @return void
  */
 public function testSetSearch()
 {
     $result = new SearchResult();
     $search = new Search();
     $search->setEntries(array(new Entry('a'), new Entry('b'), new Entry('c')));
     $result->setSearch($search);
     $other = new Search();
     $other->setEntries(array(new Entry('d'), new Entry('e'), new Entry('f')));
     $result->setSearch($search);
     $this->assertEquals(0, count($search->getEntries()), 'When old search got released from search result, it was freed from memory');
 }
Ejemplo n.º 2
0
 /**
  * Execites a search on the ldap
  *
  * @param string  $baseDn     Base distinguished name to search in (Default = configured dn)
  * @param string  $filter     Ldap filter according to RFC4515 (Default = null)
  * @param boolean $inDepth    Whether to search through all subtree depth (Default = true)
  * @param array   $attributes Filter attributes to be retrieved (Default: null)
  *
  * @return SearchResult
  */
 public function search($baseDn = null, $filter = null, $inDepth = true, $attributes = null)
 {
     $this->validateBinding();
     $result = new SearchResult();
     $baseDn = null === $baseDn ? $this->configuration['base_dn'] : $baseDn;
     $filter = null === $filter ? '(objectclass=*)' : $filter;
     $attributes = is_array($attributes) ? $attributes : null;
     $scope = $inDepth ? SearchInterface::SCOPE_ALL : SearchInterface::SCOPE_ONE;
     try {
         $search = $this->connection->search($scope, $baseDn, $filter, $attributes);
     } catch (NoResultException $e) {
         return $result;
     }
     $result->setSearch($search);
     return $result;
 }