public function LdapServer::searchAllBaseDns in Lightweight Directory Access Protocol (LDAP) 7.2
Same name and namespace in other branches
- 8.2 ldap_servers/LdapServer.class.php \LdapServer::searchAllBaseDns()
Perform an LDAP search on all base dns and aggregate into one result.
@remaining params mimick ldap_search() function params
Parameters
string $filter: The search filter. such as sAMAccountName=jbarclay. attribute values (e.g. jbarclay) should be esacaped before calling.
array $attributes: List of desired attributes. If omitted, we only return "dn".
Return value
array An array of matching entries->attributes (will have 0 elements if search returns no results), or FALSE on error on any of the basedn queries.
File
- ldap_servers/
LdapServer.class.php, line 741 - Defines server classes and related functions.
Class
- LdapServer
- LDAP Server Class.
Code
public function searchAllBaseDns($filter, $attributes = [], $attrsonly = 0, $sizelimit = 0, $timelimit = 0, $deref = NULL, $scope = LDAP_SCOPE_SUBTREE) {
$all_entries = [];
// Need to search on all basedns one at a time.
foreach ($this->basedn as $base_dn) {
// No attributes, just dns needed.
$entries = $this
->search($base_dn, $filter, $attributes, $attrsonly, $sizelimit, $timelimit, $deref, $scope);
// If error in any search, return false.
if ($entries === FALSE) {
return FALSE;
}
if (count($all_entries) == 0) {
$all_entries = $entries;
unset($all_entries['count']);
}
else {
$existing_count = count($all_entries);
unset($entries['count']);
foreach ($entries as $i => $entry) {
$all_entries[$existing_count + $i] = $entry;
}
}
}
$all_entries['count'] = count($all_entries);
return $all_entries;
}