password != $_SESSION['confwiz_masterpwd']) { require("../config/conflogin.php"); exit; } // check if user clicked cancel button if ($_POST['cancel']) { @unlink("../../config/" . $_SESSION['confwiz_config']->file . ".conf"); metarefresh('../config/conflogin.php'); } // check if all suffixes exist $conf = $_SESSION['confwiz_config']; $new_suffs = array(); if ($conf->get_UserSuffix() && ($conf->get_UserSuffix() != "")) { $info = @ldap_search($_SESSION['confwiz_ldap']->server, $conf->get_UserSuffix(), "", array()); $res = @ldap_get_entries($_SESSION['confwiz_ldap']->server, $info); if (!$res && !in_array($conf->get_UserSuffix(), $new_suffs)) $new_suffs[] = $conf->get_UserSuffix(); } if ($conf->get_GroupSuffix() && ($conf->get_GroupSuffix() != "")) { $info = @ldap_search($_SESSION['confwiz_ldap']->server, $conf->get_GroupSuffix(), "", array()); $res = @ldap_get_entries($_SESSION['confwiz_ldap']->server, $info); if (!$res && !in_array($conf->get_GroupSuffix(), $new_suffs)) $new_suffs[] = $conf->get_GroupSuffix(); } if ($conf->get_HostSuffix() && ($conf->get_HostSuffix() != "")) { $info = @ldap_search($_SESSION['confwiz_ldap']->server, $conf->get_HostSuffix(), "", array()); $res = @ldap_get_entries($_SESSION['confwiz_ldap']->server, $info); if (!$res && !in_array($conf->get_HostSuffix(), $new_suffs)) $new_suffs[] = $conf->get_HostSuffix(); } if ($conf->is_samba3() && $conf->get_DomainSuffix() && ($conf->get_DomainSuffix() != "")) { $info = @ldap_search($_SESSION['confwiz_ldap']->server, $conf->get_DomainSuffix(), "", array()); $res = @ldap_get_entries($_SESSION['confwiz_ldap']->server, $info); if (!$res && !in_array($conf->get_DomainSuffix(), $new_suffs)) $new_suffs[] = $conf->get_DomainSuffix(); } if (sizeof($new_suffs) > 0) { // check if user wanted to create suffixes if ($_POST['createsuff']) { $fail = array(); $errors = array(); // add entries for ($i = 0; $i < sizeof($new_suffs); $i++) { // check if entry is already present $info = @ldap_search($_SESSION['confwiz_ldap']->server, $new_suffs[$i], "", array()); $res = @ldap_get_entries($_SESSION['confwiz_ldap']->server, $info); if ($res) continue; $suff = $new_suffs[$i]; // generate DN and attributes $tmp = explode(",", $suff); $name = explode("=", $tmp[0]); array_shift($tmp); $end = implode(",", $tmp); if ($name[0] != "ou") { // add root entry $attr = array(); $attr[$name[0]] = $name[1]; $attr['objectClass'] = 'organization'; $dn = $suff; if (!@ldap_add($_SESSION['confwiz_ldap']->server(), $dn, $attr)) { $fail[] = $suff; continue; } } else { // add organizational unit $name = $name[1]; $attr = array(); $attr['objectClass'] = "organizationalunit"; $attr['ou'] = $name; $dn = $suff; if (!@ldap_add($_SESSION['confwiz_ldap']->server(), $dn, $attr)) { // check if we have to add parent entries if (ldap_errno($_SESSION['confwiz_ldap']->server()) == 32) { $temp = explode(",", $suff); $subsuffs = array(); // make list of subsuffixes for ($k = 0; $k < sizeof($temp); $k++) { $part = explode("=", $temp[$k]); if ($part[0] == "ou") $subsuffs[] = implode(",", array_slice($temp, $k)); else { $subsuffs[] = implode(",", array_slice($temp, $k)); break; } } // create missing entries for ($k = sizeof($subsuffs) - 1; $k >= 0; $k--) { // check if subsuffix is present $info = @ldap_search($_SESSION['confwiz_ldap']->server, $subsuffs[$k], "", array()); $res = @ldap_get_entries($_SESSION['confwiz_ldap']->server, $info); if (!$res) { $suffarray = explode(",", $subsuffs[$k]); $headarray = explode("=", $suffarray[0]); if ($headarray[0] == "ou") { // add ou entry $attr = array(); $attr['objectClass'] = 'organizationalunit'; $attr['ou'] = $headarray[1]; $dn = $subsuffs[$k]; if (!@ldap_add($_SESSION['confwiz_ldap']->server(), $dn, $attr)) { $fail[] = $suff; $error[] = ldap_error($_SESSION['confwiz_ldap']->server()); break; } } else { // add root entry $attr = array(); $attr['objectClass'] = 'organization'; $attr[$headarray[0]] = $headarray[1]; $dn = $subsuffs[$k]; if (!@ldap_add($_SESSION['confwiz_ldap']->server(), $dn, $attr)) { $fail[] = $suff; $error[] = ldap_error($_SESSION['confwiz_ldap']->server()); break; } } } } } else { $fail[] = $suff; $error[] = ldap_error($_SESSION['confwiz_ldap']->server()); } } } } // show errors if (sizeof($fail) > 0) { echo $_SESSION['header']; echo "
\n"; echo "\n"; echo "
\n"; echo "\n"; // print failed suffixes for ($i = 0; $i < sizeof($fail); $i++) { StatusMessage("ERROR", _("Failed to create entry!") . "
\n"; echo "\n"; echo "