Ejemplo n.º 1
0
 /**
  * Execute a search query in the entire LDAP tree
  *
  * @param string $filter msdn.microsoft.com/En-US/library/aa746475.aspx
  * @param array $fields specific attributes to be returned. Defaults are set
  * as $fields in this class. DN is always returned, no matter what.
  *
  * @return array $entry|null
  */
 public function find($filter, array $fields = [])
 {
     $results = $this->ldap->search($this->base_dn, $this->search_filter . '=' . $filter, $fields ? $fields : $this->fields);
     if (count($results) > 0) {
         $entry = $this->ldap->entry($results);
         // Returning a single LDAP entry
         if (isset($entry[0]) && !empty($entry[0])) {
             return $entry[0];
         }
     }
     return null;
 }
Ejemplo n.º 2
0
 /**
  * Execute a search query in the LDAP Base DN.
  *
  * @param string $identifier msdn.microsoft.com/En-US/library/aa746475.aspx
  * @param array  $fields     specific attributes to be returned
  *
  * @return array $entry
  * @throws EmptySearchResultException
  */
 public function find($identifier, array $fields = [])
 {
     // Get all result entries
     $results = $this->ldap->search($this->base_dn, $this->search_filter . '=' . $identifier, $fields ?: $this->search_fields);
     if (count($results) > 0) {
         $entry = $this->ldap->entry($results);
         // Returning a single LDAP entry
         if (isset($entry[0]) && !empty($entry[0])) {
             return $entry[0];
         }
     }
     throw new EmptySearchResultException();
 }