summaryrefslogtreecommitdiff
path: root/www/admin/sharedfolder/sf.php.in
diff options
context:
space:
mode:
Diffstat (limited to 'www/admin/sharedfolder/sf.php.in')
-rw-r--r--www/admin/sharedfolder/sf.php.in27
1 files changed, 21 insertions, 6 deletions
diff --git a/www/admin/sharedfolder/sf.php.in b/www/admin/sharedfolder/sf.php.in
index 8f42802..9343c12 100644
--- a/www/admin/sharedfolder/sf.php.in
+++ b/www/admin/sharedfolder/sf.php.in
@@ -219,13 +219,28 @@ if( !$errors ) {
if (($result=ldap_read($ldap->connection,$dn,"(objectclass=*)")) &&
($entry=ldap_first_entry($ldap->connection,$result)) &&
($oldattrs=ldap_get_attributes($ldap->connection,$entry))) {
- if (!ldap_add($ldap->connection,$newdn, $ldap_object)
- || !ldap_delete($ldap->connection,$dn)) {
- array_push($errors, sprintf(_("LDAP Error: could not rename %1\$s to %2\$s: %3\$s"), $dn, $newdn,
- ldap_error($ldap->connection)));
- } else {
- $messages[] = _('Shared folder updated');
+
+ // Try to rename the object
+ if (!ldap_rename($ldap->connection, $dn, "cn=" . $ldap_object['cn'], $sf_root, true)) {
+ array_push($errors, sprintf(_("LDAP Error: could not rename %s to %s: %s"), $dn,
+ $newdn, ldap_error($ldap->connection)));
+ }
+ if( !$errors ) {
+ // Renaming was ok, now try to modify the object accordingly
+ if (!ldap_modify($ldap->connection, $newdn, $ldap_object)) {
+ // While this should not happen, in case it does, we need to revert the
+ // renaming
+ array_push($errors, sprintf(_("LDAP Error: could not modify %s to %s: %s"), $newdn,
+ ldap_error($ldap->connection)));
+ $old_dn = substr($dn, 0, strlen($dn) - strlen($sf_root) - 1);
+ ldap_rename($ldap->connection, $newdn, $old_dn, $sf_root, true);
+ } else {
+ // everything is fine and we can move on
+ $messages[] = _('Shared folder updated');
+ $dn = $newdn;
+ }
}
+
$dn = $newdn;
} else array_push($errors, sprintf(_("LDAP Error: could not read %s: %s"), $dn,
ldap_error($ldap->connection)));