diff --git a/lam/templates/ou_edit.php b/lam/templates/ou_edit.php index 84498442..895c5cdb 100644 --- a/lam/templates/ou_edit.php +++ b/lam/templates/ou_edit.php @@ -64,20 +64,12 @@ if ($_POST['submit']) { } // delete ou, user was sure elseif (($_POST['type'] == "del_usr") && ($_POST['sure'])) { - // check for sub entries - $sr = ldap_list($_SESSION['ldap']->server(), $_POST['usersuff_d'], "ObjectClass=*", array("")); - $info = ldap_get_entries($_SESSION['ldap']->server(), $sr); - if ($info['count'] == 0) { - $ret = @ldap_delete($_SESSION['ldap']->server(), $_POST['usersuff_d']); - if ($ret) { - $message = _("OU deleted successfully."); - } - else { - $error = _("Unable to delete OU!"); - } + $ret = @ldap_delete($_SESSION['ldap']->server(), $_POST['usersuff_d']); + if ($ret) { + $message = _("OU deleted successfully."); } else { - $error = _("OU is not empty!"); + $error = _("Unable to delete OU!"); } } // do not delete ou @@ -88,9 +80,9 @@ if ($_POST['submit']) { // ask if user is sure to delete elseif ($_POST['type'] == "del_usr") { // check for sub entries - $sr = ldap_list($_SESSION['ldap']->server(), $_POST['usersuff_d'], "ObjectClass=*", array("")); - $info = ldap_get_entries($_SESSION['ldap']->server(), $sr); - if ($info['count'] == 0) { + $sr = @ldap_list($_SESSION['ldap']->server(), $_POST['usersuff_d'], "ObjectClass=*", array("")); + $info = @ldap_get_entries($_SESSION['ldap']->server(), $sr); + if ($sr && $info['count'] == 0) { $text = "
\n" . "

" . _("Do you really want to delete this OU?") . " " . "\n" . "
\n

" . $_POST['usersuff_d'] . "

\n" . @@ -104,7 +96,7 @@ if ($_POST['submit']) { ""; } else { - $error = _("OU is not empty!"); + $error = _("OU is not empty or invalid!"); } } @@ -137,20 +129,12 @@ if ($_POST['submit']) { } // delete ou, user was sure elseif (($_POST['type'] == "del_grp") && ($_POST['sure'])) { - // check for sub entries - $sr = ldap_list($_SESSION['ldap']->server(), $_POST['groupsuff_d'], "ObjectClass=*", array("")); - $info = ldap_get_entries($_SESSION['ldap']->server(), $sr); - if ($info['count'] == 0) { - $ret = @ldap_delete($_SESSION['ldap']->server(), $_POST['groupsuff_d']); - if ($ret) { - $message = _("OU deleted successfully."); - } - else { - $error = _("Unable to delete OU!"); - } + $ret = @ldap_delete($_SESSION['ldap']->server(), $_POST['groupsuff_d']); + if ($ret) { + $message = _("OU deleted successfully."); } else { - $error = _("OU is not empty!"); + $error = _("Unable to delete OU!"); } } // do not delete ou @@ -161,9 +145,9 @@ if ($_POST['submit']) { // ask if user is sure to delete elseif ($_POST['type'] == "del_grp") { // check for sub entries - $sr = ldap_list($_SESSION['ldap']->server(), $_POST['groupsuff_d'], "ObjectClass=*", array("")); - $info = ldap_get_entries($_SESSION['ldap']->server(), $sr); - if ($info['count'] == 0) { + $sr = @ldap_list($_SESSION['ldap']->server(), $_POST['groupsuff_d'], "ObjectClass=*", array("")); + $info = @ldap_get_entries($_SESSION['ldap']->server(), $sr); + if ($sr && $info['count'] == 0) { $text = "
\n" . "

" . _("Do you really want to delete this OU?") . " " . "\n" . "
\n

" . $_POST['groupsuff_d'] . "

\n" . @@ -177,7 +161,7 @@ if ($_POST['submit']) { ""; } else { - $error = _("OU is not empty!"); + $error = _("OU is not empty or invalid!"); } } @@ -210,20 +194,12 @@ if ($_POST['submit']) { } // delete ou, user was sure elseif (($_POST['type'] == "del_hst") && ($_POST['sure'])) { - // check for sub entries - $sr = ldap_list($_SESSION['ldap']->server(), $_POST['hostsuff_d'], "ObjectClass=*", array("")); - $info = ldap_get_entries($_SESSION['ldap']->server(), $sr); - if ($info['count'] == 0) { - $ret = @ldap_delete($_SESSION['ldap']->server(), $_POST['hostsuff_d']); - if ($ret) { - $message = _("OU deleted successfully."); - } - else { - $error = _("Unable to delete OU!"); - } + $ret = @ldap_delete($_SESSION['ldap']->server(), $_POST['hostsuff_d']); + if ($ret) { + $message = _("OU deleted successfully."); } else { - $error = _("OU is not empty!"); + $error = _("Unable to delete OU!"); } } // do not delete ou @@ -234,9 +210,9 @@ if ($_POST['submit']) { // ask if user is sure to delete elseif ($_POST['type'] == "del_hst") { // check for sub entries - $sr = ldap_list($_SESSION['ldap']->server(), $_POST['hostsuff_d'], "ObjectClass=*", array("")); - $info = ldap_get_entries($_SESSION['ldap']->server(), $sr); - if ($info['count'] == 0) { + $sr = @ldap_list($_SESSION['ldap']->server(), $_POST['hostsuff_d'], "ObjectClass=*", array("")); + $info = @ldap_get_entries($_SESSION['ldap']->server(), $sr); + if ($sr && $info['count'] == 0) { $text = "
\n" . "

" . _("Do you really want to delete this OU?") . " " . "\n" . "
\n

" . $_POST['hostsuff_d'] . "

\n" . @@ -250,7 +226,7 @@ if ($_POST['submit']) { ""; } else { - $error = _("OU is not empty!"); + $error = _("OU is not empty or invalid!"); } }