mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-28 16:24:04 +02:00
parent
e408630e34
commit
cee639d689
@ -702,11 +702,23 @@ class LdapConnection implements Selectable, Inspectable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$unfoldAttribute = $query->getUnfoldAttribute();
|
||||||
|
if ($unfoldAttribute) {
|
||||||
|
foreach ($query->getFilter()->listFilteredColumns() as $filterColumn) {
|
||||||
|
$fieldKey = array_search($filterColumn, $fields, true);
|
||||||
|
if ($fieldKey === false || is_string($fieldKey)) {
|
||||||
|
$fields[] = $filterColumn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$results = @ldap_search(
|
$results = @ldap_search(
|
||||||
$ds,
|
$ds,
|
||||||
$query->getBase() ?: $this->rootDn,
|
$query->getBase() ?: $this->rootDn,
|
||||||
(string) $query,
|
(string) $query,
|
||||||
array_values($fields),
|
$unfoldAttribute
|
||||||
|
? array_unique(array_values($fields))
|
||||||
|
: array_values($fields),
|
||||||
0, // Attributes and values
|
0, // Attributes and values
|
||||||
$serverSorting && $limit ? $offset + $limit : 0
|
$serverSorting && $limit ? $offset + $limit : 0
|
||||||
);
|
);
|
||||||
@ -728,20 +740,21 @@ class LdapConnection implements Selectable, Inspectable
|
|||||||
$count = 0;
|
$count = 0;
|
||||||
$entries = array();
|
$entries = array();
|
||||||
$entry = ldap_first_entry($ds, $results);
|
$entry = ldap_first_entry($ds, $results);
|
||||||
$unfoldAttribute = $query->getUnfoldAttribute();
|
|
||||||
do {
|
do {
|
||||||
if ($unfoldAttribute) {
|
if ($unfoldAttribute) {
|
||||||
$rows = $this->cleanupAttributes(ldap_get_attributes($ds, $entry), $fields, $unfoldAttribute);
|
$rows = $this->cleanupAttributes(ldap_get_attributes($ds, $entry), $fields, $unfoldAttribute);
|
||||||
if (is_array($rows)) {
|
if (is_array($rows)) {
|
||||||
// TODO: Register the DN the same way as a section name in the ArrayDatasource!
|
// TODO: Register the DN the same way as a section name in the ArrayDatasource!
|
||||||
foreach ($rows as $row) {
|
foreach ($rows as $row) {
|
||||||
$count += 1;
|
if ($query->getFilter()->matches($row)) {
|
||||||
if (! $serverSorting || $offset === 0 || $offset < $count) {
|
$count += 1;
|
||||||
$entries[] = $row;
|
if (! $serverSorting || $offset === 0 || $offset < $count) {
|
||||||
}
|
$entries[] = $row;
|
||||||
|
}
|
||||||
|
|
||||||
if ($serverSorting && $limit > 0 && $limit === count($entries)) {
|
if ($serverSorting && $limit > 0 && $limit === count($entries)) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -813,10 +826,19 @@ class LdapConnection implements Selectable, Inspectable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$unfoldAttribute = $query->getUnfoldAttribute();
|
||||||
|
if ($unfoldAttribute) {
|
||||||
|
foreach ($query->getFilter()->listFilteredColumns() as $filterColumn) {
|
||||||
|
$fieldKey = array_search($filterColumn, $fields, true);
|
||||||
|
if ($fieldKey === false || is_string($fieldKey)) {
|
||||||
|
$fields[] = $filterColumn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$count = 0;
|
$count = 0;
|
||||||
$cookie = '';
|
$cookie = '';
|
||||||
$entries = array();
|
$entries = array();
|
||||||
$unfoldAttribute = $query->getUnfoldAttribute();
|
|
||||||
do {
|
do {
|
||||||
// Do not request the pagination control as a critical extension, as we want the
|
// Do not request the pagination control as a critical extension, as we want the
|
||||||
// server to return results even if the paged search request cannot be satisfied
|
// server to return results even if the paged search request cannot be satisfied
|
||||||
@ -835,7 +857,9 @@ class LdapConnection implements Selectable, Inspectable
|
|||||||
$ds,
|
$ds,
|
||||||
$base,
|
$base,
|
||||||
$queryString,
|
$queryString,
|
||||||
array_values($fields),
|
$unfoldAttribute
|
||||||
|
? array_unique(array_values($fields))
|
||||||
|
: array_values($fields),
|
||||||
0, // Attributes and values
|
0, // Attributes and values
|
||||||
$serverSorting && $limit ? $offset + $limit : 0
|
$serverSorting && $limit ? $offset + $limit : 0
|
||||||
);
|
);
|
||||||
@ -873,13 +897,15 @@ class LdapConnection implements Selectable, Inspectable
|
|||||||
if (is_array($rows)) {
|
if (is_array($rows)) {
|
||||||
// TODO: Register the DN the same way as a section name in the ArrayDatasource!
|
// TODO: Register the DN the same way as a section name in the ArrayDatasource!
|
||||||
foreach ($rows as $row) {
|
foreach ($rows as $row) {
|
||||||
$count += 1;
|
if ($query->getFilter()->matches($row)) {
|
||||||
if (! $serverSorting || $offset === 0 || $offset < $count) {
|
$count += 1;
|
||||||
$entries[] = $row;
|
if (! $serverSorting || $offset === 0 || $offset < $count) {
|
||||||
}
|
$entries[] = $row;
|
||||||
|
}
|
||||||
|
|
||||||
if ($serverSorting && $limit > 0 && $limit === count($entries)) {
|
if ($serverSorting && $limit > 0 && $limit === count($entries)) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1010,6 +1036,14 @@ class LdapConnection implements Selectable, Inspectable
|
|||||||
&& isset($cleanedAttributes[$unfoldAttribute])
|
&& isset($cleanedAttributes[$unfoldAttribute])
|
||||||
&& is_array($cleanedAttributes[$unfoldAttribute])
|
&& is_array($cleanedAttributes[$unfoldAttribute])
|
||||||
) {
|
) {
|
||||||
|
$siblings = array();
|
||||||
|
foreach ($loweredFieldMap as $loweredName => $requestedNames) {
|
||||||
|
if (is_array($requestedNames) && in_array($unfoldAttribute, $requestedNames, true)) {
|
||||||
|
$siblings = array_diff($requestedNames, array($unfoldAttribute));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$values = $cleanedAttributes[$unfoldAttribute];
|
$values = $cleanedAttributes[$unfoldAttribute];
|
||||||
unset($cleanedAttributes[$unfoldAttribute]);
|
unset($cleanedAttributes[$unfoldAttribute]);
|
||||||
$baseRow = (object) $cleanedAttributes;
|
$baseRow = (object) $cleanedAttributes;
|
||||||
@ -1017,6 +1051,10 @@ class LdapConnection implements Selectable, Inspectable
|
|||||||
foreach ($values as $value) {
|
foreach ($values as $value) {
|
||||||
$row = clone $baseRow;
|
$row = clone $baseRow;
|
||||||
$row->{$unfoldAttribute} = $value;
|
$row->{$unfoldAttribute} = $value;
|
||||||
|
foreach ($siblings as $sibling) {
|
||||||
|
$row->{$sibling} = $value;
|
||||||
|
}
|
||||||
|
|
||||||
$rows[] = $row;
|
$rows[] = $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user