summaryrefslogtreecommitdiff
path: root/www/admin/user/user.php.in
diff options
context:
space:
mode:
Diffstat (limited to 'www/admin/user/user.php.in')
-rw-r--r--www/admin/user/user.php.in36
1 files changed, 22 insertions, 14 deletions
diff --git a/www/admin/user/user.php.in b/www/admin/user/user.php.in
index 3c67f3e..a9711d0 100644
--- a/www/admin/user/user.php.in
+++ b/www/admin/user/user.php.in
@@ -656,22 +656,30 @@ switch( $action ) {
unset($explodeddn['count']);
unset($explodeddn[0]);
$tmpbasedn = join(",",$explodeddn);
- if ( !$errors && !ldap_rename($ldap->connection,$dn,$tmprdn,$tmpbasedn,false) ) {
- array_push($errors, sprintf(_("LDAP Error: Could not rename %1\$s to %2\$s: %3\$s"), $dn, $tmprdn,
- ldap_error($ldap->connection)));
- }
- if ( !$errors && !ldap_add($ldap->connection,$newdn, $ldap_object) ) {
- array_push($errors, sprintf(_("LDAP Error: Could not rename %1\$s to %2\$s: %3\$s"), $dn, $newdn,
- ldap_error($ldap->connection)));
- }
- if( !$errors ) {
- if( !ldap_delete($ldap->connection,$tmprdn.','.$tmpbasedn)) {
- array_push($errors, sprintf(_("LDAP Error: Could not remove old entry %s,%s: %s"),
- $tmprdn, $tmpbasedn,
- ldap_error($ldap->connection)));
+
+ if ( !$errors ) {
+ // Try to rename the object
+ if (!ldap_rename($ldap->connection, $dn, "cn=" . $ldap_object['cn'], $domain_dn, 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($domain_dn) - 1);
+ ldap_rename($ldap->connection, $newdn, $old_dn, $domain_dn, true);
+ } else {
+ // everything is fine and we can move on
+ $messages[] = sprintf( _("%s successfully updated"), $newdn);
+ $dn = $newdn;
+ }
}
+ $dn = $newdn;
}
- $dn = $newdn;
} else array_push($errors, sprintf(_("LDAP Error: Could not read %s: %s"), $dn,
ldap_error($ldap->connection)));
} else {