\n"); echo ("\n"); // add/edit domain if (($_GET['action'] == "edit") || ($_GET['action'] == "new")) { // get list of domains $domlist = $_SESSION['ldap']->search_domains($_SESSION['config']->get_domainSuffix()); // get possible suffixes $domsuff = $_SESSION['ldap']->search_units($_SESSION['config']->get_domainSuffix()); if ($_GET['action'] == "edit") { // load attributes from domain for ($i = 0; $i < sizeof($domlist); $i++) { if ($domlist[$i]->dn == $_GET['DN']) { $domain = $domlist[$i]; break; } } // get suffix $tmp_arr = explode(",", $domain->dn); array_shift($tmp_arr); $domain_suffix = implode(",", $tmp_arr); } else { $domain = new samba3domain(); $domain_suffix = $_SESSION['config']->get_domainSuffix(); } // display page echo "\n"; echo "\n"; echo "Domain Management\n"; echo "\n"; echo "\n"; echo "\n"; // print message, if needed if ($_SESSION['domain_message']) echo "

" . $_SESSION['domain_message'] . "

 

"; // print fieldset echo "
\n"; echo "

 

\n"; echo "
\n"; echo "" . _("Domain Settings") . "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; // next RID echo "\n"; echo "\n"; echo "\n"; echo "\n"; // next user RID echo "\n"; echo "\n"; echo "\n"; echo "\n"; // next RID echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; // next RID echo "\n"; echo "\n"; echo "\n"; echo "
\n"; // domain name echo "" . _("Domain name") . ":\n"; echo "\n"; if ($_GET['action'] == "edit") { echo $domain->name . "\n"; } else echo "\n"; echo "
  
\n"; // domain suffix echo "" . _("Suffix") . ": \n"; echo "\n"; echo ""; echo "
  
\n"; // domain SID echo "" . _("Domain SID") . ": \n"; echo "\n"; if ($_GET['action'] == "edit") { echo $domain->SID . "\n"; } else echo "\n"; echo "
  
" . _("Next RID") . ": \n"; echo "nextRID . "\">\n"; echo "
" . _("Next User RID") . ": \n"; echo "nextUserRID . "\">\n"; echo "
" . _("Next Group RID") . ": \n"; echo "nextGroupRID . "\">\n"; echo "
  
" . _("Algorithmic RID Base") . ": \n"; if ($_GET['action'] == "edit") echo $domain->RIDbase . "\n"; else echo "RIDbase . "\">\n"; echo "
\n"; echo "
\n"; // post DN and old RID values echo "dn . "\">"; echo "nextRID . "\">"; echo "nextUserRID . "\">"; echo "nextGroupRID . "\">"; // edit or add operation if ($_GET['action'] == "edit") echo ""; else echo ""; echo "

 

\n"; echo "

\n"; echo "\n"; echo "\n"; echo "\n"; echo "

\n"; echo "
\n"; echo "\n"; echo "\n"; } // delete domain, ask if sure elseif ($_GET['action'] == "delete") { // remove "\'" and make array $DNs = str_replace("\\'", "", $_GET['DN']); $DNs = explode(";", $DNs); // display page echo "\n"; echo "\n"; echo "Domain Management\n"; echo "\n"; echo "\n"; echo "\n"; echo "

 

\n"; echo "

" . _("Delete domain(s)?") . "

\n"; echo "

 

\n"; for ($i = 0; $i < sizeof($DNs); $i++) { echo "

" . $DNs[$i] . "

\n"; } echo "

 

\n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "
"; echo "\n"; echo "\n"; } // save domain elseif ($_POST['sub_save']) { echo "\n"; echo "\n"; echo "Domain Management\n"; echo "\n"; echo "\n"; echo "\n"; // check input if ($_POST['add'] && !eregi("^[a-z0-9_\\-]+$", $_POST['dom_name'])) StatusMessage("ERROR", "", _("Domain name is invalid!")); elseif ($_POST['add'] && !eregi("^S-[0-9]-[0-9]-[0-9]{2,2}-[0-9]*-[0-9]*-[0-9]*$", $_POST['dom_SID'])) { StatusMessage("ERROR", "", _("Samba 3 domain SID is invalid!")); } elseif ($_POST['dom_nextRID'] && !is_numeric($_POST['dom_nextRID'])) StatusMessage("ERROR", "", _("Next RID is not a number!")); elseif ($_POST['dom_nextUserRID'] && !is_numeric($_POST['dom_nextUserRID'])) StatusMessage("ERROR", "", _("Next user RID is not a number!")); elseif ($_POST['dom_nextGroupRID'] && !is_numeric($_POST['dom_nextGroupRID'])) StatusMessage("ERROR", "", _("Next group RID is not a number!")); elseif ($_POST['add'] && !is_numeric($_POST['dom_RIDbase'])) StatusMessage("ERROR", "", _("Algorithmic RID base is not a number!")); // edit entry elseif ($_POST['edit'] == "yes") { $success = true; // change attributes $attr = array(); if ($_POST['dom_nextRID'] != $_POST['dom_oldnextRID']) $attr['sambaNextRid'] = $_POST['dom_nextRID']; if ($_POST['dom_nextUserRID'] != $_POST['dom_oldnextUserRID']) $attr['sambaNextUserRid'] = $_POST['dom_nextUserRID']; if ($_POST['dom_nextGroupRID'] != $_POST['dom_oldnextGroupRID']) $attr['sambaNextGroupRid'] = $_POST['dom_nextGroupRID']; if (sizeof($attr) > 0) $success = ldap_modify($_SESSION['ldap']->server(), $_POST['dom_DN'], $attr); // change suffix $RDN = explode(",", $_POST['dom_DN']); $RDN = $RDN[0]; $newDN = $RDN . "," . $_POST['dom_suffix']; if ($_POST['dom_DN'] != $newDN) { $success = ldap_rename($_SESSION['ldap']->server(), $_POST['dom_DN'], $RDN, $_POST['dom_suffix'], true); } if ($success) StatusMessage("INFO", "Domain has been modified.", $DN); else StatusMessage("ERROR", "", "Failed to modify domain!"); } // add entry else { $DN = "sambaDomainName" . "=" . $_POST['dom_name'] . "," . $_POST['dom_suffix']; $attr = array(); $attr['objectclass'] = "sambaDomain"; $attr['sambaDomainName'] = $_POST['dom_name']; $attr['sambaSID'] = $_POST['dom_SID']; if ($_POST['dom_nextRID']) $attr['sambaNextRid'] = $_POST['dom_nextRID']; if ($_POST['dom_nextGroupRID']) $attr['sambaNextGroupRid'] = $_POST['dom_nextGroupRID']; if ($_POST['dom_nextUserRID']) $attr['sambaNextUserRid'] = $_POST['dom_nextUserRID']; $attr['sambaAlgorithmicRidBase'] = $_POST['dom_RIDbase']; // write to LDAP if (ldap_add($_SESSION['ldap']->server(), $DN, $attr)) { StatusMessage("INFO", "Domain has been created.", $DN); } else StatusMessage("ERROR", "", "Failed to add domain!"); } echo "

 

\n"; echo "

" . _("Back to domain list") . "

\n"; echo "\n"; echo "\n"; } // back to list elseif ($_POST['sub_back']) { echo(""); } // delete domain, user was sure elseif ($_POST['sub_delete']) { $DNs = explode(";", $_POST['delDN']); // display page echo "\n"; echo "\n"; echo "Domain Management\n"; echo "\n"; echo "\n"; echo "\n"; // delete DNs for ($i = 0; $i < sizeof($DNs); $i++) { if (ldap_delete($_SESSION['ldap']->server(), $DNs[$i])) StatusMessage("INFO", "Domain deleted successfully.", $DNs[$i]); else StatusMessage("ERROR", "Unable to delete domain!", $DNs[$i]); } echo "

 

\n"; echo "

" . _("Back to domain list") . "

\n"; echo "\n"; echo "\n"; } ?>