summaryrefslogtreecommitdiff
path: root/www
diff options
context:
space:
mode:
authorGunnar Wrobel <wrobel@pardus.de>2007-03-16 12:17:24 (GMT)
committerGunnar Wrobel <wrobel@pardus.de>2007-03-16 12:17:24 (GMT)
commit73cfd70c6291d1e137fa53b8f7e576e3d1ca9c3c (patch)
treec85f9cabc7ae0e17b3b51da1e8952405b0cc791b /www
parent024d0e5ead0c3f2606e2cd51aa9396230dbd14bb (diff)
downloadkolab-webadmin-73cfd70c6291d1e137fa53b8f7e576e3d1ca9c3c.tar.gz
2007-03-16 Gunnar Wrobel <p@rdus.de>
* www/admin/user/user.php.in: * www/admin/sharedfolder/sf.php.in: * www/admin/maintainer/maintainer.php.in: * www/admin/domainmaintainer/domainmaintainer.php.in: * www/admin/distributionlist/list.php.in: * www/admin/administrator/admin.php.in: * www/admin/addressbook/addr.php.in: Fixed for the new LDAP overlays introduced in http://kolab.org/cgi-bin/viewcvs-kolab.cgi/server/kolabd/kolabd/templates/slapd.conf.template.in.diff?r1=1.9&r2=1.10 Tries to fix the following issues: https://intevation.de/roundup/kolab/issue1614 https://intevation.de/roundup/kolab/issue1652 https://intevation.de/roundup/kolab/issue1654
Diffstat (limited to 'www')
-rw-r--r--www/admin/addressbook/addr.php.in23
-rw-r--r--www/admin/administrator/admin.php.in38
-rw-r--r--www/admin/distributionlist/list.php.in27
-rw-r--r--www/admin/domainmaintainer/domainmaintainer.php.in37
-rw-r--r--www/admin/maintainer/maintainer.php.in38
-rw-r--r--www/admin/sharedfolder/sf.php.in27
-rw-r--r--www/admin/user/user.php.in36
7 files changed, 135 insertions, 91 deletions
diff --git a/www/admin/addressbook/addr.php.in b/www/admin/addressbook/addr.php.in
index bb956dd..3b42c09 100644
--- a/www/admin/addressbook/addr.php.in
+++ b/www/admin/addressbook/addr.php.in
@@ -204,13 +204,28 @@ if( !$errors ) {
($entry=ldap_first_entry($ldap->connection,$result)) &&
($oldattrs=ldap_get_attributes($ldap->connection,$entry))) {
foreach( $ldap_object as $k => $v ) if( $v == array() ) unset( $ldap_object[$k] );
- if (!ldap_add($ldap->connection,$newdn, $ldap_object) || !ldap_delete($ldap->connection,$dn)) {
+
+ // Try to rename the object
+ if (!ldap_rename($ldap->connection, $dn, "cn=" . $ldap_object['cn'], $addressbook_root, true)) {
array_push($errors, sprintf(_("LDAP Error: could not rename %s to %s: %s"), $dn,
$newdn, ldap_error($ldap->connection)));
- } else {
- $messages[] = sprintf( _("%s successfully updated"), $newdn);
}
- $dn = $newdn;
+ 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($addressbook_root) - 1);
+ ldap_rename($ldap->connection, $newdn, $old_dn, $addressbook_root, true);
+ } else {
+ // everything is fine and we can move on
+ $messages[] = sprintf( _("%s successfully updated"), $newdn);
+ $dn = $newdn;
+ }
+ }
+
} else {
array_push($errors,sprintf(_("LDAP Error: could not read %s: %s"), $dn,
ldap_error($ldap->connection)));
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 {
diff --git a/www/admin/distributionlist/list.php.in b/www/admin/distributionlist/list.php.in
index e2d9904..58ea132 100644
--- a/www/admin/distributionlist/list.php.in
+++ b/www/admin/distributionlist/list.php.in
@@ -190,13 +190,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[] = _('Distribution List updated');
+
+ // Try to rename the object
+ if (!ldap_rename($ldap->connection, $dn, "cn=" . $ldap_object['cn'], $dl_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($dl_root) - 1);
+ ldap_rename($ldap->connection, $newdn, $old_dn, $dl_root, true);
+ } else {
+ // everything is fine and we can move on
+ $messages[] = _('Distribution List updated');
+ $dn = $newdn;
+ }
}
+
$dn = $newdn;
} else array_push($errors, sprintf( _("LDAP Error: Could not read %s: %s"), $dn,
ldap_error($ldap->connection)));
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);
diff --git a/www/admin/maintainer/maintainer.php.in b/www/admin/maintainer/maintainer.php.in
index 3b82132..5786e3e 100644
--- a/www/admin/maintainer/maintainer.php.in
+++ b/www/admin/maintainer/maintainer.php.in
@@ -208,31 +208,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 maintainer group
- $groupdn = 'cn=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));
- }
- }
- $dn = $newdn;
} else array_push($errors, sprintf(_("LDAP Error: could not read %s: %s"), $dn,
ldap_error($ldap->connection)));
} else {
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)));
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 {