get_ActiveTypes();
// check if submit button was pressed
if ($_POST['submit']) {
// check user input
for ($i = 0; $i < sizeof($types); $i++) {
// new ou
if ($_POST['type'] == "new_" . $types[$i]) {
// create ou if valid
if (eregi("^[a-z0-9 _\\-]+$", $_POST['newname_' . $types[$i]])) {
// check if ou already exists
$new_dn = "ou=" . $_POST['newname_' . $types[$i]] . "," . $_POST['parentsuff_' . $types[$i]];
if (!in_array($new_dn, $_SESSION['ldap']->search_units($_POST['parentsuff_' . $types[$i]]))) {
// add new ou
$ou = array();
$ou['objectClass'] = "organizationalunit";
$ou['ou'] = $_POST['newname_' . $types[$i]];
$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['newname_' . $types[$i]];
}
}
// delete ou, user was sure
elseif (($_POST['type'] == "del_" . $types[$i]) && ($_POST['sure'])) {
$ret = @ldap_delete($_SESSION['ldap']->server(), $_POST['deletename_' . $types[$i]]);
if ($ret) {
$message = _("OU deleted successfully.");
}
else {
$error = _("Unable to delete OU!");
}
}
// do not delete ou
elseif (($_POST['type'] == "del_" . $types[$i]) && ($_POST['abort'])) {
display_main();
exit;
}
// ask if user is sure to delete
elseif ($_POST['type'] == "del_" . $types[$i]) {
// check for sub entries
$sr = @ldap_list($_SESSION['ldap']->server(), $_POST['deletename_' . $types[$i]], "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['deletename_' . $types[$i]] . "
\n" . "