summaryrefslogtreecommitdiff
path: root/www/admin/administrator/admin.php.in
diff options
context:
space:
mode:
Diffstat (limited to 'www/admin/administrator/admin.php.in')
-rw-r--r--www/admin/administrator/admin.php.in38
1 files changed, 17 insertions, 21 deletions
diff --git a/www/admin/administrator/admin.php.in b/www/admin/administrator/admin.php.in
index 65d1bb9..e8d5103 100644
--- a/www/admin/administrator/admin.php.in
+++ b/www/admin/administrator/admin.php.in
@@ -211,31 +211,27 @@ switch( $action ) {
$ldap_object['uid'] = $oldattrs['uid'][0];
if( empty($ldap_object['userPassword']) )
$ldap_object['userPassword'] = $oldattrs['userPassword'][0];
- if (!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)));
+
+ // Try to rename the object
+ if (!ldap_rename($ldap->connection, $dn, "cn=" . $ldap_object['cn'], "cn=internal,".$domain_dn, true)) {
+ array_push($errors, sprintf(_("LDAP Error: could not rename %s to %s: %s"), $dn,
+ $newdn, ldap_error($ldap->connection)));
+ }
if( !$errors ) {
- if( !ldap_delete($ldap->connection,$dn)) {
- array_push($errors, sprintf(_("LDAP Error: could not remove old entry %s: %s"), $dn,
+ // 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("cn=internal,".$domain_dn) - 1);
+ ldap_rename($ldap->connection, $newdn, $old_dn, "cn=internal,".$domain_dn, true);
+ } else {
+ // everything is fine and we can move on
+ $messages[] = sprintf( _("%s successfully updated"), $newdn);
+ $dn = $newdn;
}
}
- if( !$errors ) {
- // Update admin group
- $groupdn = 'cn=admin,cn=internal,'.$domain_dn;
- if( !ldap_mod_add( $ldap->connection,
- $groupdn,
- array( 'member' => $newdn ) ) ) {
- $errors[] = sprintf(_("LDAP Error: Could not add new group entry %s: %s"), $newdn,
- ldap_error($ldap->connection));
- }
- if( !$errors && !ldap_mod_del($ldap->connection,$groupdn,
- array( 'member' => $dn ) ) ) {
- $errors[] = sprintf( _("LDAP Error: Could not remove old group entry %s: %s"), $dn,
- ldap_error($ldap->connection));
- }
- }
- $dn = $newdn;
} else array_push($errors,sprintf(_("LDAP Error: could not read %s: %s"), $dn,
ldap_error($ldap->connection)));
} else {