summaryrefslogtreecommitdiff
path: root/www/admin/domainmaintainer/domainmaintainer.php.in
diff options
context:
space:
mode:
Diffstat (limited to 'www/admin/domainmaintainer/domainmaintainer.php.in')
-rw-r--r--www/admin/domainmaintainer/domainmaintainer.php.in37
1 files changed, 18 insertions, 19 deletions
diff --git a/www/admin/domainmaintainer/domainmaintainer.php.in b/www/admin/domainmaintainer/domainmaintainer.php.in
index 253b6a2..efd11b3 100644
--- a/www/admin/domainmaintainer/domainmaintainer.php.in
+++ b/www/admin/domainmaintainer/domainmaintainer.php.in
@@ -193,29 +193,28 @@ 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,
- ldap_error($ldap->connection)));
+ // 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);
}
}
+
if( !$errors ) {
- // Update maintainer group
- $groupdn = 'cn=domain-maintainer,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));
- }
if( $auth->group() == 'admin' || $auth->group() == 'maintainer' ) {
if( !$errors ) {
$domains = $ldap->domainsForMaintainerDn($dn);