You are here

function LDAPInterface::search in LDAP integration 6

Same name and namespace in other branches
  1. 5.2 ldap_integration/LDAPInterface.php \LDAPInterface::search()
  2. 5 ldap_integration/LDAPInterface.php \LDAPInterface::search()

File

includes/LDAPInterface.inc, line 213
LDAPInterface class definition.

Class

LDAPInterface
@file LDAPInterface class definition.

Code

function search($base_dn, $filter, $attributes = array()) {
  $ret = array();

  // For the AD the '\,' should be replaced by the '\\,' in the search filter.
  $filter = preg_replace('/\\\\,/', '\\\\\\,', $filter);
  set_error_handler(array(
    'LDAPInterface',
    'void_error_handler',
  ));
  $x = @ldap_search($this->connection, $base_dn, $filter, $attributes);
  restore_error_handler();
  if ($x && ldap_count_entries($this->connection, $x)) {
    $ret = ldap_get_entries($this->connection, $x);
  }
  return $ret;
}