get_ActiveTypes(); // check if deletion was canceled if (isset($_POST['abort'])) { display_main(); exit; } // check if submit button was pressed if (isset($_POST['createOU']) || isset($_POST['deleteOU'])) { // new ou if (isset($_POST['createOU'])) { // create ou if valid if (preg_match("/^[a-z0-9 _\\-]+$/i", $_POST['newOU'])) { // check if ou already exists $new_dn = "ou=" . $_POST['newOU'] . "," . $_POST['parentOU']; if (!in_array($new_dn, $_SESSION['ldap']->search_units($_POST['parentOU']))) { // add new ou $ou = array(); $ou['objectClass'] = "organizationalunit"; $ou['ou'] = $_POST['newOU']; $ret = @ldap_add($_SESSION['ldap']->server(), $new_dn, $ou); if ($ret) { $message = _("New OU created successfully."); } else { $error = _("Unable to create new OU!"); } } else $error = _("OU already exists!"); } // show errormessage if ou is invalid else { $error = _("OU is invalid!") . "
" . $_POST['newOU']; } } // delete ou, user was sure elseif (isset($_POST['deleteOU']) && isset($_POST['sure'])) { $ret = @ldap_delete($_SESSION['ldap']->server(), $_POST['deletename']); if ($ret) { $message = _("OU deleted successfully."); } else { $error = _("Unable to delete OU!"); } } // ask if user is sure to delete elseif (isset($_POST['deleteOU'])) { // check for sub entries $sr = @ldap_list($_SESSION['ldap']->server(), $_POST['deleteableOU'], "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['deleteableOU'] . "

\n" . "
\n" . "
\n" . "\n" . "\n" . "\n" . "\n" . "
"; } else { $error = _("OU is not empty or invalid!"); } } // print header include 'main_header.php'; // display messages if ($error || $message || $text) { if (isset($text)) echo $text; elseif (isset($error)) { StatusMessage("ERROR", "", $error); echo ("
" . _("Back to OU-Editor") . "\n"); } else { StatusMessage("INFO", "", $message); echo ("
" . _("Back to OU-Editor") . "\n"); } } echo ("\n"); exit; } display_main(); /** * Displays the main page of the OU editor */ function display_main() { // display main page include 'main_header.php'; echo "

" . _("OU editor") . "

"; echo ("
\n"); echo ("
\n"); $types = array(); $typeList = $_SESSION['config']->get_ActiveTypes(); for ($i = 0; $i < sizeof($typeList); $i++) { $types[$typeList[$i]] = getTypeAlias($typeList[$i]); } natcasesort($types); $options = ""; foreach ($types as $name => $title) { $options .= "\n"; $units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_Suffix($name)); for ($u = 0; $u < sizeof($units); $u++) { $options .= "\n"; } $options .= "\n"; } echo ("
" . _("OU editor") . "
\n"); echo ("\n"); // new OU echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ""; echo "\n"; echo ("\n"); echo "\n"; // delete OU echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ""; echo "\n"; echo ("\n"); echo ("
" . _("New organizational unit") . " \n"); echo (""; echo " "; echo ""; printHelpLink(getHelp('', '601'), '601'); echo "
 
" . _("Delete organizational unit") . " \n"); echo (" "; echo " "; echo ""; printHelpLink(getHelp('', '602'), '602'); echo "
\n"); echo ("
\n"); echo ("
\n"); echo ("
\n"); echo ("\n"); }