LdapConnection: Do not require calling array_flip for method cleanupAttributes()
Seems to be a relict of an earlier implementation.. refs #10370
This commit is contained in:
parent
666e67b405
commit
e408630e34
|
@ -308,12 +308,8 @@ class LdapCapabilities
|
||||||
ldap_error($ds)
|
ldap_error($ds)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$cap = new LdapCapabilities(
|
|
||||||
$connection->cleanupAttributes(
|
$cap = new LdapCapabilities($connection->cleanupAttributes(ldap_get_attributes($ds, $entry), $fields));
|
||||||
ldap_get_attributes($ds, $entry),
|
|
||||||
array_flip($fields)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return $cap;
|
return $cap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -731,12 +731,7 @@ class LdapConnection implements Selectable, Inspectable
|
||||||
$unfoldAttribute = $query->getUnfoldAttribute();
|
$unfoldAttribute = $query->getUnfoldAttribute();
|
||||||
do {
|
do {
|
||||||
if ($unfoldAttribute) {
|
if ($unfoldAttribute) {
|
||||||
$rows = $this->cleanupAttributes(
|
$rows = $this->cleanupAttributes(ldap_get_attributes($ds, $entry), $fields, $unfoldAttribute);
|
||||||
ldap_get_attributes($ds, $entry),
|
|
||||||
array_flip($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) {
|
||||||
|
@ -760,7 +755,7 @@ class LdapConnection implements Selectable, Inspectable
|
||||||
if (! $serverSorting || $offset === 0 || $offset < $count) {
|
if (! $serverSorting || $offset === 0 || $offset < $count) {
|
||||||
$entries[ldap_get_dn($ds, $entry)] = $this->cleanupAttributes(
|
$entries[ldap_get_dn($ds, $entry)] = $this->cleanupAttributes(
|
||||||
ldap_get_attributes($ds, $entry),
|
ldap_get_attributes($ds, $entry),
|
||||||
array_flip($fields)
|
$fields
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -874,12 +869,7 @@ class LdapConnection implements Selectable, Inspectable
|
||||||
$entry = ldap_first_entry($ds, $results);
|
$entry = ldap_first_entry($ds, $results);
|
||||||
do {
|
do {
|
||||||
if ($unfoldAttribute) {
|
if ($unfoldAttribute) {
|
||||||
$rows = $this->cleanupAttributes(
|
$rows = $this->cleanupAttributes(ldap_get_attributes($ds, $entry), $fields, $unfoldAttribute);
|
||||||
ldap_get_attributes($ds, $entry),
|
|
||||||
array_flip($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) {
|
||||||
|
@ -903,7 +893,7 @@ class LdapConnection implements Selectable, Inspectable
|
||||||
if (! $serverSorting || $offset === 0 || $offset < $count) {
|
if (! $serverSorting || $offset === 0 || $offset < $count) {
|
||||||
$entries[ldap_get_dn($ds, $entry)] = $this->cleanupAttributes(
|
$entries[ldap_get_dn($ds, $entry)] = $this->cleanupAttributes(
|
||||||
ldap_get_attributes($ds, $entry),
|
ldap_get_attributes($ds, $entry),
|
||||||
array_flip($fields)
|
$fields
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -965,8 +955,17 @@ class LdapConnection implements Selectable, Inspectable
|
||||||
// necessary to create another array to map attributes case insensitively to their requested counterparts.
|
// necessary to create another array to map attributes case insensitively to their requested counterparts.
|
||||||
// This does also apply the virtual alias handling. (Since an LDAP server does not handle such)
|
// This does also apply the virtual alias handling. (Since an LDAP server does not handle such)
|
||||||
$loweredFieldMap = array();
|
$loweredFieldMap = array();
|
||||||
foreach ($requestedFields as $name => $alias) {
|
foreach ($requestedFields as $alias => $name) {
|
||||||
$loweredFieldMap[strtolower($name)] = is_string($alias) ? $alias : $name;
|
$loweredName = strtolower($name);
|
||||||
|
if (isset($loweredFieldMap[$loweredName])) {
|
||||||
|
if (! is_array($loweredFieldMap[$loweredName])) {
|
||||||
|
$loweredFieldMap[$loweredName] = array($loweredFieldMap[$loweredName]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$loweredFieldMap[$loweredName][] = is_string($alias) ? $alias : $name;
|
||||||
|
} else {
|
||||||
|
$loweredFieldMap[$loweredName] = is_string($alias) ? $alias : $name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$cleanedAttributes = array();
|
$cleanedAttributes = array();
|
||||||
|
@ -984,12 +983,18 @@ class LdapConnection implements Selectable, Inspectable
|
||||||
$requestedAttributeName = isset($loweredFieldMap[strtolower($attribute_name)])
|
$requestedAttributeName = isset($loweredFieldMap[strtolower($attribute_name)])
|
||||||
? $loweredFieldMap[strtolower($attribute_name)]
|
? $loweredFieldMap[strtolower($attribute_name)]
|
||||||
: $attribute_name;
|
: $attribute_name;
|
||||||
$cleanedAttributes[$requestedAttributeName] = $attribute_value;
|
if (is_array($requestedAttributeName)) {
|
||||||
|
foreach ($requestedAttributeName as $requestedName) {
|
||||||
|
$cleanedAttributes[$requestedName] = $attribute_value;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$cleanedAttributes[$requestedAttributeName] = $attribute_value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The result may not contain all requested fields, so populate the cleaned
|
// The result may not contain all requested fields, so populate the cleaned
|
||||||
// result with the missing fields and their value being set to null
|
// result with the missing fields and their value being set to null
|
||||||
foreach ($requestedFields as $name => $alias) {
|
foreach ($requestedFields as $alias => $name) {
|
||||||
if (! is_string($alias)) {
|
if (! is_string($alias)) {
|
||||||
$alias = $name;
|
$alias = $name;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue