mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-26 23:34:08 +02:00
LdapConnection: Count properly in case the result may get unfolded
refs #9772
This commit is contained in:
parent
575875481a
commit
624f5050b7
@ -358,9 +358,25 @@ class LdapConnection implements Selectable, Inspectable
|
|||||||
*/
|
*/
|
||||||
public function count(LdapQuery $query)
|
public function count(LdapQuery $query)
|
||||||
{
|
{
|
||||||
$ds = $this->getConnection();
|
|
||||||
$this->bind();
|
$this->bind();
|
||||||
|
|
||||||
|
if (($unfoldAttribute = $query->getUnfoldAttribute()) !== null) {
|
||||||
|
$desiredColumns = $query->getColumns();
|
||||||
|
if (isset($desiredColumns[$unfoldAttribute])) {
|
||||||
|
$fields = array($unfoldAttribute => $desiredColumns[$unfoldAttribute]);
|
||||||
|
} elseif (in_array($unfoldAttribute, $desiredColumns, true)) {
|
||||||
|
$fields = array($unfoldAttribute);
|
||||||
|
} else {
|
||||||
|
throw new ProgrammingError(
|
||||||
|
'The attribute used to unfold a query\'s result must be selected'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$res = $this->runQuery($query, $fields);
|
||||||
|
return count($res);
|
||||||
|
}
|
||||||
|
|
||||||
|
$ds = $this->getConnection();
|
||||||
$results = @ldap_search(
|
$results = @ldap_search(
|
||||||
$ds,
|
$ds,
|
||||||
$query->getBase() ?: $this->getDn(),
|
$query->getBase() ?: $this->getDn(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user