public function Server::ldapQuery in Lightweight Directory Access Protocol (LDAP) 8.3
Execute LDAP query and return LDAP records.
Parameters
int $scope: Scope of search (base, subtree or one level).
array|resource $params: See pagedLdapQuery() $params.
Return value
resource|bool Array of LDAP entries.
4 calls to Server::ldapQuery()
- Server::checkDnExists in ldap_servers/
src/ Entity/ Server.php - Does dn exist for this server?
- Server::checkDnExistsIncludeData in ldap_servers/
src/ Entity/ Server.php - Does dn exist for this server and what is its data?
- Server::pagedLdapQuery in ldap_servers/
src/ Entity/ Server.php - Execute a paged LDAP query and return entries as one aggregated array.
- Server::search in ldap_servers/
src/ Entity/ Server.php - Perform an LDAP search.
File
- ldap_servers/
src/ Entity/ Server.php, line 911
Class
- Server
- Defines the Server entity.
Namespace
Drupal\ldap_servers\EntityCode
public function ldapQuery($scope, array $params) {
$result = FALSE;
$this
->connectAndBindIfNotAlready();
switch ($scope) {
case Server::SCOPE_SUBTREE:
$result = @ldap_search($this->connection, $params['base_dn'], $params['filter'], $params['attributes'], $params['attrsonly'], $params['sizelimit'], $params['timelimit'], $params['deref']);
if ($params['sizelimit'] && $this
->ldapErrorNumber() == self::LDAP_SIZELIMIT_EXCEEDED) {
// False positive error thrown.
// Do not return result limit error when $sizelimit specified.
}
elseif ($this
->hasError()) {
$this->logger
->error('ldap_search() function error. LDAP Error: %message, ldap_search() parameters: %query', [
'%message' => $this
->formattedError($this
->ldapErrorNumber()),
'%query' => isset($params['query_display']) ? $params['query_display'] : NULL,
]);
}
break;
case Server::SCOPE_BASE:
$result = @ldap_read($this->connection, $params['base_dn'], $params['filter'], $params['attributes'], $params['attrsonly'], $params['sizelimit'], $params['timelimit'], $params['deref']);
if ($params['sizelimit'] && $this
->ldapErrorNumber() == self::LDAP_SIZELIMIT_EXCEEDED) {
// False positive error thrown.
// Do not result limit error when $sizelimit specified.
}
elseif ($this
->hasError()) {
$this->logger
->error('ldap_read() function error. LDAP Error: %message, ldap_read() parameters: %query', [
'%message' => $this
->formattedError($this
->ldapErrorNumber()),
'%query' => @$params['query_display'],
]);
}
break;
case Server::SCOPE_ONE_LEVEL:
$result = @ldap_list($this->connection, $params['base_dn'], $params['filter'], $params['attributes'], $params['attrsonly'], $params['sizelimit'], $params['timelimit'], $params['deref']);
if ($params['sizelimit'] && $this
->ldapErrorNumber() == self::LDAP_SIZELIMIT_EXCEEDED) {
// False positive error thrown.
// Do not result limit error when $sizelimit specified.
}
elseif ($this
->hasError()) {
$this->logger
->error('ldap_list() function error. LDAP Error: %message, ldap_list() parameters: %query', [
'%message' => $this
->formattedError($this
->ldapErrorNumber()),
'%query' => $params['query_display'],
]);
}
break;
}
return $result;
}