search_units($_POST['usersuff_n']))) { // add new ou $ou = array(); $ou['objectClass'] = "organizationalunit"; $ou['ou'] = $_POST['newsuff_u']; $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['newsuff_u']; } } // delete ou, user was sure elseif (($_POST['type'] == "del_usr") && ($_POST['sure'])) { $ret = @ldap_delete($_SESSION['ldap']->server(), $_POST['usersuff_d']); if ($ret) { $message = _("OU deleted successfully."); } else { $error = _("Unable to delete OU!"); } } // do not delete ou elseif (($_POST['type'] == "del_usr") && ($_POST['abort'])) { display_main(); exit; } // 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 ($sr && $info['count'] == 0) { $text = "
\n" . "

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

" . $_POST['usersuff_d'] . "

\n" . "
\n" . "
\n" . "\n" . "\n" . "\n" . "\n" . "\n" . "
"; } else { $error = _("OU is not empty or invalid!"); } } // group operations // new group ou if ($_POST['type'] == "new_grp") { // create ou if valid if (eregi("^[a-z0-9 _\\-]+$", $_POST['newsuff_g'])) { // check if ou already exists $new_dn = "ou=" . $_POST['newsuff_g'] . "," . $_POST['groupsuff_n']; if (!in_array(strtolower($new_dn), $_SESSION['ldap']->search_units($_POST['groupsuff_n']))) { // add new ou $ou = array(); $ou['objectClass'] = "organizationalunit"; $ou['ou'] = $_POST['newsuff_g']; $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['newsuff_g']; } } // delete ou, user was sure elseif (($_POST['type'] == "del_grp") && ($_POST['sure'])) { $ret = @ldap_delete($_SESSION['ldap']->server(), $_POST['groupsuff_d']); if ($ret) { $message = _("OU deleted successfully."); } else { $error = _("Unable to delete OU!"); } } // do not delete ou elseif (($_POST['type'] == "del_grp") && ($_POST['abort'])) { display_main(); exit; } // 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 ($sr && $info['count'] == 0) { $text = "
\n" . "

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

" . $_POST['groupsuff_d'] . "

\n" . "
\n" . "
\n" . "\n" . "\n" . "\n" . "\n" . "\n" . "
"; } else { $error = _("OU is not empty or invalid!"); } } // host operations // new host ou if ($_POST['type'] == "new_hst") { // create ou if valid if (eregi("^[a-z0-9 _\\-]+$", $_POST['newsuff_h'])) { // check if ou already exists $new_dn = "ou=" . $_POST['newsuff_h'] . "," . $_POST['hostsuff_n']; if (!in_array(strtolower($new_dn), $_SESSION['ldap']->search_units($_POST['hostsuff_n']))) { // add new ou $ou = array(); $ou['objectClass'] = "organizationalunit"; $ou['ou'] = $_POST['newsuff_h']; $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['newsuff_h']; } } // delete ou, user was sure elseif (($_POST['type'] == "del_hst") && ($_POST['sure'])) { $ret = @ldap_delete($_SESSION['ldap']->server(), $_POST['hostsuff_d']); if ($ret) { $message = _("OU deleted successfully."); } else { $error = _("Unable to delete OU!"); } } // do not delete ou elseif (($_POST['type'] == "del_hst") && ($_POST['abort'])) { display_main(); exit; } // 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 ($sr && $info['count'] == 0) { $text = "
\n" . "

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

" . $_POST['hostsuff_d'] . "

\n" . "
\n" . "
\n" . "\n" . "\n" . "\n" . "\n" . "\n" . "
"; } else { $error = _("OU is not empty or invalid!"); } } // domain operations // new domain ou if ($_POST['type'] == "new_dom") { // create ou if valid if (eregi("^[a-z0-9 _\\-]+$", $_POST['newsuff_d'])) { // check if ou already exists $new_dn = "ou=" . $_POST['newsuff_d'] . "," . $_POST['domsuff_n']; if (!in_array(strtolower($new_dn), $_SESSION['ldap']->search_units($_POST['domsuff_n']))) { // add new ou $ou = array(); $ou['objectClass'] = "organizationalunit"; $ou['ou'] = $_POST['newsuff_d']; $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['newsuff_d']; } } // delete ou, user was sure elseif (($_POST['type'] == "del_dom") && ($_POST['sure'])) { $ret = @ldap_delete($_SESSION['ldap']->server(), $_POST['domsuff_d']); if ($ret) { $message = _("OU deleted successfully."); } else { $error = _("Unable to delete OU!"); } } // do not delete ou elseif (($_POST['type'] == "del_dom") && ($_POST['abort'])) { display_main(); exit; } // ask if user is sure to delete elseif ($_POST['type'] == "del_dom") { // check for sub entries $sr = @ldap_list($_SESSION['ldap']->server(), $_POST['domsuff_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['domsuff_d'] . "

\n" . "
\n" . "
\n" . "\n" . "\n" . "\n" . "\n" . "\n" . "
"; } else { $error = _("OU is not empty or invalid!"); } } // print header echo $_SESSION['header']; echo ("OU-Editor\n"); echo ("\n"); echo ("\n"); echo ("\n"); // display messages if ($error || $message || $text) { if ($text) echo $text; elseif ($error) { StatusMessage("ERROR", "", $error); echo ("
" . _("Back to OU-Editor") . "\n"); } else { StatusMessage("INFO", "", $message); echo ("
" . _("Back to OU-Editor") . "\n"); } } echo ("\n"); exit; } else display_main(); function display_main() { // generate lists of possible suffixes $usr_units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_UserSuffix()); $grp_units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_GroupSuffix()); $hst_units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_HostSuffix()); $dom_units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_DomainSuffix()); // display main page echo $_SESSION['header']; echo ("OU-Editor\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("
\n"); echo ("
\n"); // user OUs echo ("
" . _("Users") . "\n"); echo ("\n"); // new OU echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); // delete OU echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("
" . _("New organizational unit") . ": \n"); echo ("". _("Help") ."
" . _("Delete organizational unit") . ": \n"); echo (" ". _("Help") ."
\n"); echo ("
\n"); echo ("
\n"); // group OUs echo ("
" . _("Groups") . "\n"); echo ("\n"); // new OU echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); // delete OU echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("
" . _("New organizational unit") . ": \n"); echo ("". _("Help") ."
" . _("Delete organizational unit") . ": \n"); echo (" ". _("Help") ."
\n"); echo ("
\n"); echo ("
\n"); // host OUs echo ("
" . _("Samba Hosts") . "\n"); echo ("\n"); // new OU echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); // delete OU echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("
" . _("New organizational unit") . ": \n"); echo ("". _("Help") ."
" . _("Delete organizational unit") . ": \n"); echo (" ". _("Help") ."
\n"); echo ("
\n"); echo ("
\n"); // domain OUs echo ("
" . _("Domains") . "\n"); echo ("\n"); // new OU echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); // delete OU echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("\n"); echo ("
" . _("New organizational unit") . ": \n"); echo ("". _("Help") ."
" . _("Delete organizational unit") . ": \n"); echo (" ". _("Help") ."
\n"); echo ("
\n"); echo ("
\n"); echo (""); echo ("
\n"); echo ("\n"); }