diff options
author | alecpl <alec@alec.pl> | 2009-08-29 18:41:17 +0000 |
---|---|---|
committer | alecpl <alec@alec.pl> | 2009-08-29 18:41:17 +0000 |
commit | e83f035887e3a463568465673ae92f365788c2a5 (patch) | |
tree | 4c6fee06d0c28dc88e21e6042052ddbb14cf659e /program/include/rcube_ldap.php | |
parent | 0131ec9724ce5e1e1abff188a2976c447f826a04 (diff) |
- Fix LDAP contact update when RDN field is changed (#1485788)
Diffstat (limited to 'program/include/rcube_ldap.php')
-rw-r--r-- | program/include/rcube_ldap.php | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/program/include/rcube_ldap.php b/program/include/rcube_ldap.php index 37edca7aa..b13e88395 100644 --- a/program/include/rcube_ldap.php +++ b/program/include/rcube_ldap.php @@ -480,32 +480,43 @@ class rcube_ldap extends rcube_addressbook } // end if } // end foreach - // Update the entry as required. $dn = base64_decode($id); + + // Update the entry as required. if (!empty($deletedata)) { // Delete the fields. - $res = ldap_mod_del($this->conn, $dn, $deletedata); - if ($res === FALSE) { + if (!ldap_mod_del($this->conn, $dn, $deletedata)) return false; - } // end if } // end if if (!empty($replacedata)) { + // Handle RDN change + if ($replacedata[$this->prop['LDAP_rdn']]) { + $newdn = $this->prop['LDAP_rdn'].'='.$replacedata[$this->prop['LDAP_rdn']].','.$this->prop['base_dn']; + if ($dn != $newdn) { + $newrdn = $this->prop['LDAP_rdn'].'='.$replacedata[$this->prop['LDAP_rdn']]; + unset($replacedata[$this->prop['LDAP_rdn']]); + } + } // Replace the fields. - $res = ldap_mod_replace($this->conn, $dn, $replacedata); - if ($res === FALSE) { - return false; + if (!empty($replacedata)) { + if (!ldap_mod_replace($this->conn, $dn, $replacedata)) + return false; } // end if } // end if if (!empty($newdata)) { // Add the fields. - $res = ldap_mod_add($this->conn, $dn, $newdata); - if ($res === FALSE) { + if (!ldap_mod_add($this->conn, $dn, $newdata)) return false; - } // end if } // end if + // Handle RDN change + if (!empty($newrdn)) { + if (@ldap_rename($this->conn, $dn, $newrdn, NULL, TRUE)) + return base64_encode($newdn); + } + return true; } |