mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-25 23:04:51 +02:00
lib/ldap: Use ldap_count_entries for counting the result set
This commit is contained in:
parent
fa25ce7f2f
commit
9b22b24561
@ -358,10 +358,30 @@ class LdapConnection implements Selectable, Inspectable
|
|||||||
*/
|
*/
|
||||||
public function count(LdapQuery $query)
|
public function count(LdapQuery $query)
|
||||||
{
|
{
|
||||||
|
$ds = $this->getConnection();
|
||||||
$this->bind();
|
$this->bind();
|
||||||
|
|
||||||
$res = $this->runQuery($query, array());
|
$results = @ldap_search(
|
||||||
return count($res);
|
$ds,
|
||||||
|
$query->getBase() ?: $this->getDn(),
|
||||||
|
(string) $query,
|
||||||
|
array('dn'),
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($results === false) {
|
||||||
|
if (ldap_errno($ds) !== self::LDAP_NO_SUCH_OBJECT) {
|
||||||
|
throw new LdapException(
|
||||||
|
'LDAP count query "%s" (base %s) failed: %s',
|
||||||
|
(string) $query,
|
||||||
|
$query->getBase() ?: $this->getDn(),
|
||||||
|
ldap_error($ds)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ldap_count_entries($ds, $results);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user