You are here

function LdapQuery::query in Lightweight Directory Access Protocol (LDAP) 7

Same name and namespace in other branches
  1. 8.2 ldap_query/LdapQuery.class.php \LdapQuery::query()
  2. 7.2 ldap_query/LdapQuery.class.php \LdapQuery::query()

File

ldap_query/LdapQuery.class.php, line 108
Defines server classes and related functions.

Class

LdapQuery
LDAP Server Class

Code

function query() {
  ldap_server_module_load_include('php', 'ldap_servers', 'LdapServer.class');
  $ldap_server = new LdapServer($this->sid);
  $ldap_server
    ->connect();
  $ldap_server
    ->bind();
  $results = array();
  $count = 0;

  // for debugging paginations, set: $ldap_server->searchPageStart = NULL, 0, 1, ... ; $ldap_server->searchPageEnd = NULL, 0, 1, ...;
  foreach ($this->baseDn as $base_dn) {
    $result = $ldap_server
      ->search($base_dn, $this->filter, $this->attributes, 0, $this->sizelimit, $this->timelimit, $this->deref, $this->scope);
    if ($result !== FALSE && $result['count'] > 0) {
      $count = $count + $result['count'];
      $results = array_merge($results, $result);
    }
  }
  $results['count'] = $count;
  return $results;
}