fix attribute names on loading

This commit is contained in:
Roland Gruber 2006-07-23 15:03:35 +00:00
parent 2e3e4accca
commit 8f3f93c87d
1 changed files with 16 additions and 0 deletions

View File

@ -1230,11 +1230,20 @@ class accountContainer {
// get correct object class names, aliases and attributes // get correct object class names, aliases and attributes
$objectClasses = array(); $objectClasses = array();
$aliases = array(); $aliases = array();
$ldapAttributesTemp = array();
foreach ($modules as $module) { foreach ($modules as $module) {
$moduleObj = new $module($this->type); $moduleObj = new $module($this->type);
$objectClasses = array_merge($objectClasses, $moduleObj->getManagedObjectClasses()); $objectClasses = array_merge($objectClasses, $moduleObj->getManagedObjectClasses());
$aliases = array_merge($aliases, $moduleObj->getLDAPAliases()); $aliases = array_merge($aliases, $moduleObj->getLDAPAliases());
$ldapAttributesTemp = array_merge($ldapAttributesTemp, $moduleObj->getManagedAttributes());
} }
// build lower case attribute names
$ldapAttributes = array();
for ($i = 0; $i < sizeof($ldapAttributesTemp); $i++) {
$ldapAttributes[strtolower($ldapAttributesTemp[$i])] = $ldapAttributesTemp[$i];
unset($ldapAttributes[$i]);
}
$ldapAttributesKeys = array_keys($ldapAttributes);
// convert alias names to lower case (for easier comparison) // convert alias names to lower case (for easier comparison)
$aliasKeys = array_keys($aliases); $aliasKeys = array_keys($aliases);
for ($i = 0; $i < sizeof($aliasKeys); $i++) { for ($i = 0; $i < sizeof($aliasKeys); $i++) {
@ -1273,6 +1282,13 @@ class accountContainer {
$attributes[$aliases[strtolower($keys[$i])]] = $attributes[$keys[$i]]; $attributes[$aliases[strtolower($keys[$i])]] = $attributes[$keys[$i]];
unset($attributes[$keys[$i]]); unset($attributes[$keys[$i]]);
} }
// fix attribute names
elseif (in_array(strtolower($keys[$i]), $ldapAttributesKeys)) {
if ($keys[$i] != $ldapAttributes[strtolower($keys[$i])]) {
$attributes[$ldapAttributes[strtolower($keys[$i])]] = $attributes[$keys[$i]];
unset($attributes[$keys[$i]]);
}
}
} }
} }
return $attributes; return $attributes;