diff options
| author | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2009-08-29 18:41:17 +0000 |
|---|---|---|
| committer | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2009-08-29 18:41:17 +0000 |
| commit | e6acc84d685860d9e2345af3a07cda2074d92fe8 (patch) | |
| tree | df40259f62f48e60c6b75cc6bc58e12c9448854d /roundcubemail/program/include/rcube_ldap.php | |
| parent | bbe73e1571d7d0a98c9814cbbd4779f0614fab95 (diff) | |
- Fix LDAP contact update when RDN field is changed (#1485788)
git-svn-id: https://svn.roundcube.net/trunk@2889 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'roundcubemail/program/include/rcube_ldap.php')
| -rw-r--r-- | roundcubemail/program/include/rcube_ldap.php | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/roundcubemail/program/include/rcube_ldap.php b/roundcubemail/program/include/rcube_ldap.php index 37edca7aa..b13e88395 100644 --- a/roundcubemail/program/include/rcube_ldap.php +++ b/roundcubemail/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; } |
