summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-04-20 09:04:55 (GMT)
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-04-20 10:21:02 (GMT)
commit8eb7357b248952f16c50da9a2483e56d9f449c89 (patch)
tree16f1ec882d3414a3ba4ffbeef20a72f5a43b9d21
parent9c9a7b3e782386e50933006221a26de54748c170 (diff)
downloadkolab-wap-8eb7357b248952f16c50da9a2483e56d9f449c89.tar.gz
Bug #704: Cannot override auto_form_field values
-rw-r--r--lib/Auth/LDAP.php59
1 files changed, 35 insertions, 24 deletions
diff --git a/lib/Auth/LDAP.php b/lib/Auth/LDAP.php
index bcd3491..52ea985 100644
--- a/lib/Auth/LDAP.php
+++ b/lib/Auth/LDAP.php
@@ -568,7 +568,7 @@ class LDAP
$_user_dn = key($_user);
$_user = $this->user_info($_user_dn, array_keys($attributes));
- //console("user_edit \$_user", $_user);
+ //console("Auth::LDAP::user_edit() existing \$_user info", $_user);
// We should start throwing stuff over the fence here.
return $this->modify_entry($_user_dn, $_user[$_user_dn], $attributes);
@@ -999,7 +999,7 @@ class LDAP
$rdn_attr = $rdn_components[0];
- //console($rdn_attr);
+ //console("Auth::LDAP::modify_entry() using rdn attribute: " . $rdn_attr);
$mod_array = Array(
"add" => Array(), // For use with ldap_mod_add()
@@ -1019,15 +1019,14 @@ class LDAP
foreach ($old_attrs as $attr => $old_attr_value) {
if (array_key_exists($attr, $new_attrs)) {
- $_sort1 = false;
- $_sort2 = false;
- if (is_array($new_attrs[$attr])) {
+ if (is_array($old_attrs[$attr]) && is_array($new_attrs[$attr])) {
$_sort1 = $new_attrs[$attr];
sort($_sort1);
- }
- if (is_array($old_attr_value)) {
$_sort2 = $old_attr_value;
sort($_sort2);
+ } else {
+ $_sort1 = true;
+ $_sort2 = false;
}
if (!($new_attrs[$attr] === $old_attr_value) && !($_sort1 === $_sort2)) {
@@ -1120,12 +1119,38 @@ class LDAP
// Opportunities to set false include failed ldap commands.
$result = true;
+ if (is_array($attributes['rename']) && !empty($attributes['rename'])) {
+ $olddn = $attributes['rename']['dn'];
+ $newrdn = $attributes['rename']['new_rdn'];
+ if (!empty($attributes['rename']['new_parent'])) {
+ $new_parent = $attributes['rename']['new_parent'];
+ } else {
+ $new_parent = null;
+ }
+
+ //console("Attempt to rename $olddn to $newrdn,$new_parent");
+
+ $result = ldap_rename($this->conn, $olddn, $newrdn, $new_parent, true);
+ if ($result) {
+ if ($new_parent) {
+ $subject_dn = $newrdn . ',' . $new_parent;
+ } else {
+ $old_parent_dn_components = ldap_explode_dn($olddn, 0);
+ unset($old_parent_dn_components["count"]);
+ $old_rdn = array_shift($old_parent_dn_components);
+ $old_parent_dn = implode(",", $old_parent_dn_components);
+ $subject_dn = $newrdn . ',' . $old_parent_dn;
+ }
+ }
+
+ }
+
if (is_array($attributes['replace']) && !empty($attributes['replace'])) {
$result = ldap_mod_replace($this->conn, $subject_dn, $attributes['replace']);
}
if (!$result) {
- //console("Failed to replace the following attributes", $attributes['replace']);
+ console("Failed to replace the following attributes on subject " . $subject_dn, $attributes['replace']);
return false;
}
@@ -1134,7 +1159,7 @@ class LDAP
}
if (!$result) {
- //console("Failed to delete the following attributes", $attributes['del']);
+ console("Failed to delete the following attributes", $attributes['del']);
return false;
}
@@ -1144,24 +1169,10 @@ class LDAP
}
if (!$result) {
- //console("Failed to add the following attributes", $attributes['add']);
+ console("Failed to add the following attributes", $attributes['add']);
return false;
}
- if (is_array($attributes['rename']) && !empty($attributes['rename'])) {
- $olddn = $attributes['rename']['dn'];
- $newrdn = $attributes['rename']['new_rdn'];
- if (!empty($attributes['rename']['new_parent'])) {
- $new_parent = $attributes['rename']['new_parent'];
- } else {
- $new_parent = null;
- }
-
- //console("Attempt to rename $olddn to $newrdn,$new_parent");
-
- $result = ldap_rename($this->conn, $olddn, $newrdn, $new_parent, true);
- }
-
if (!$result) {
error_log("LDAP Error: " . $this->_errstr());
return false;