You are here

public function SimpleLdap::ldapSearch in Simple LDAP 8

Wrapper function for ldap_search().

Parameters

string $base_dn: The base DN for the directory.

string $filter: The LDAP filter to apply.

array $attributes: An array of the required attributes.

int $attrsonly: Should be set to 1 if only attribute types are wanted. If set to 0 both attributes types and attribute values are fetched which is the default behaviour.

int $sizelimit: Enables you to limit the count of entries fetched. Setting this to 0 means no limit.

int $timelimit: Sets the number of seconds how long is spend on the search. Setting this to 0 means no limit.

int $deref: Specifies how aliases should be handled during the search.

Return value

resource LDAP search result identifier.

Throws

SimpleLdapException

File

src/SimpleLdap.php, line 405

Class

SimpleLdap
A wrapper for PHP's LDAP functions, with associated helper methods.

Namespace

Drupal\simple_ldap

Code

public function ldapSearch($base_dn, $filter, $attributes = array(), $attrsonly = 0, $sizelimit = 0, $timelimit = 0, $deref = NULL) {
  $return = @ldap_search($this->connection
    ->getResource(), $base_dn, $filter, $attributes, $attrsonly, $sizelimit, $timelimit, $this
    ->getDefaultDeref($deref));
  if ($return === FALSE) {
    throw new SimpleLdapException('ldap_search wrapper: ', $this->connection
      ->getResource());
  }
  return $return;
}