diff --git a/lam/HISTORY b/lam/HISTORY
index dcbcff90..eb8c988e 100644
--- a/lam/HISTORY
+++ b/lam/HISTORY
@@ -1,4 +1,5 @@
??? 0.5.3
+ - accounts are now deleted with subentries
- fixed bugs:
-> fixed problems with case-insensitive DNs
diff --git a/lam/TODO b/lam/TODO
index 26be8410..7aafeaa0 100644
--- a/lam/TODO
+++ b/lam/TODO
@@ -7,5 +7,4 @@
0.5.3
- InetOrgPerson: jpgPhoto
- - delete entries recursively
\ No newline at end of file
diff --git a/lam/VERSION b/lam/VERSION
index cb0c939a..be14282b 100644
--- a/lam/VERSION
+++ b/lam/VERSION
@@ -1 +1 @@
-0.5.2
+0.5.3
diff --git a/lam/templates/delete.php b/lam/templates/delete.php
index dcab1136..07966418 100644
--- a/lam/templates/delete.php
+++ b/lam/templates/delete.php
@@ -82,11 +82,15 @@ if ($_GET['type']) {
echo "\n";
echo "" . _("Do you really want to remove the following accounts?") . "";
echo "
\n";
- echo "
";
+ echo "
\n"; @@ -240,4 +241,48 @@ if ($_POST['delete']) { } +/** +* Returns the number of child entries of a DN. +* +* @param string $dn DN of parent +* @return interger number of childs +*/ +function getChildCount($dn) { + $return = 0; + $sr = @ldap_search($_SESSION['ldap']->server, $dn, 'objectClass=*', array('dn'), 0); + if ($sr) { + $entries = ldap_get_entries($_SESSION['ldap']->server, $sr); + $return = $entries['count'] - 1; + } + return $return; +} + +/** +* Deletes a DN and all child entries. +* +* @param string $dn DN to delete +* @return array error messages +*/ +function deleteDN($dn) { + $errors = array(); + $sr = @ldap_list($_SESSION['ldap']->server, $dn, 'objectClass=*', array('dn'), 0); + if ($sr) { + $entries = ldap_get_entries($_SESSION['ldap']->server, $sr); + for ($i = 0; $i < $entries['count']; $i++) { + // delete recursively + $subErrors = deleteDN($entries[$i]['dn']); + for ($e = 0; $e < sizeof($subErrors); $e++) $errors[] = $subErrors[$e]; + } + } + else { + $errors[] = array ('ERROR', sprintf(_('Was unable to delete DN: %s.'), $dn), ldap_error($_SESSION['ldap']->server())); + } + // delete parent DN + $success = @ldap_delete($_SESSION['ldap']->server(), $dn); + if (!$success) { + $errors[] = array ('ERROR', sprintf(_('Was unable to delete DN: %s.'), $dn), ldap_error($_SESSION['ldap']->server())); + } + return $errors; +} + ?> |