From 938761330171e21bdaefd238233d61689e4385c5 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Thu, 19 Jun 2003 19:01:00 +0000 Subject: [PATCH] added domain SID to preferences --- lam/help/help.inc | 6 ++++++ lam/lib/config.inc | 30 +++++++++++++++++++++++++++++- lam/templates/config/confmain.php | 21 ++++++++++++++++++--- lam/templates/config/confsave.php | 9 +++++++++ lam/tests/conf-test.php | 4 ++++ 5 files changed, 66 insertions(+), 4 deletions(-) diff --git a/lam/help/help.inc b/lam/help/help.inc index eff152bb..de5dfd37 100644 --- a/lam/help/help.inc +++ b/lam/help/help.inc @@ -91,6 +91,9 @@ $helpArray = array ( "213" => array ("ext" => "FALSE", "Headline" => _("Configuration Wizard - Samba version"), "Text" => _("If you use Samba 3.x with the new LDAP schema say \"yes\" here, otherwise \"no\".". "

LAM will not work if version is wrong!")), + "214" => array ("ext" => "FALSE", "Headline" => _("Configuration Wizard - Samba domain SID"), + "Text" => _("If you use the new Samba 3.x schema enter your domain SID here.". + "

You can get your domain SID with this command: net getlocalsid")), // 300 - 399 // Roland Gruber // profile editor @@ -150,6 +153,9 @@ $helpArray = array ( "Text" => _("This is primary group for the Samba machine account.")), "371" => array ("ext" => "FALSE", "Headline" => _("Profile Editor - Domain"), "Text" => _("This is the Windows domain name.")), + // 400 - 499 + // Tilo Lutz + // account.php "400" => array ("ext" => "FALSE", "Headline" => _("Username"), "Text" => _("Username of the user which should be created. Valid characters are: a-z,0-9, .-_. Lam doesn't allow a number as first character because it's impossible to create a homedirectory starting with a number. Lam doesn't allow capital letters A-Z because it diff --git a/lam/lib/config.inc b/lam/lib/config.inc index 84ca0082..48d562ea 100644 --- a/lam/lib/config.inc +++ b/lam/lib/config.inc @@ -90,6 +90,9 @@ class Config { // if "yes" use the new LDAP schema for Samba 3.x var $samba3; + // Samba 3 domain SIDs + var $domainSID; + // constructor, loads preferences from ../config/lam.conf function Config() { $this->reload(); @@ -186,6 +189,10 @@ class Config { $this->samba3 = chop(substr($line, 8, strlen($line)-8)); continue; } + if (substr($line, 0, 11) == "domainSID: ") { + $this->domainSID = chop(substr($line, 11, strlen($line)-11)); + continue; + } } fclose($file); } @@ -202,7 +209,7 @@ class Config { $save_serverURL = $save_passwd = $save_admins = $save_suffusr = $save_suffgrp = $save_suffhst = $save_minUID = $save_maxUID = $save_minGID = $save_maxGID = $save_minMach = $save_maxMach = $save_usrlstatrr = $save_grplstatrr = $save_hstlstatrr = $save_maxlstent = $save_deflang = - $save_scriptPath = $save_scriptServer = $save_samba3 = False; + $save_scriptPath = $save_scriptServer = $save_samba3 = $save_domainSID = False; $file = fopen($conffile, "r"); $file_array = array(); while (!feof($file)) { @@ -312,6 +319,11 @@ class Config { $save_samba3 = True; continue; } + if (substr($file_array[$i], 0, 11) == "domainSID: ") { + $file_array[$i] = "domainSID: " . $this->domainSID . "\n"; + $save_domainSID = True; + continue; + } } // check if we have to add new entries (e.g. if user upgraded LAM and has an old lam.conf) if (!$save_serverURL == True) array_push($file_array, "\n\n# server address (e.g. ldap://localhost:389 or ldaps://localhost:636)\n" . "serverURL: " . $this->ServerURL); @@ -342,6 +354,7 @@ class Config { if (!$save_scriptPath == True) array_push($file_array, "\n\n# Path to external Script\n" . "scriptPath: " . $this->scriptPath); if (!$save_scriptServer == True) array_push($file_array, "\n\n# Server of external Script\n" . "scriptServer: " . $this->scriptServer); if (!$save_samba3 == True) array_push($file_array, "\n\n# Set to \"yes\" only if you use the new Samba 3.x schema.\n" . "samba3: " . $this->samba3); + if (!$save_domainSID == True) array_push($file_array, "\n\n# Samba 3 domain SID. Set only if you use the new Samba 3.x schema.\n" . "domainSID: " . $this->domainSID); $file = fopen($conffile, "w"); if ($file) { for ($i = 0; $i < sizeof($file_array); $i++) fputs($file, $file_array[$i]); @@ -358,6 +371,7 @@ class Config { function printconf() { echo _("ServerURL: ") . $this->ServerURL . "
"; echo _("Samba3: ") . $this->samba3 . "
"; + echo _("Domain SID: ") . $this->domainSID . "
"; echo _("UserSuffix: ") . $this->Suff_users . "
"; echo _("GroupSuffix: ") . $this->Suff_groups . "
"; echo _("HostSuffix: ") . $this->Suff_hosts . "
"; @@ -641,6 +655,20 @@ class Config { else StatusMessage("WARN", "", _("Config->set_samba3 failed!") . " " . $value); } + // returns the Samba domain SID (Samba 3 only) + function get_domainSID() { + return $this->domainSID; + } + + // sets the Samba domain SID (Samba 3 only) + function set_domainSID($value) { + if (!$value) $value = ""; // optional parameter + if (is_string($value) && eregi("^(S-[0-9]-[0-9]-[0-9]{2,2}-[0-9]{10,10}-[0-9]{10,10}-[0-9]{10,10})|()$", $value)) { + $this->domainSID = $value; + } + else StatusMessage("WARN", "", _("Config->set_domainSID failed!") . " " . $value); + } + } diff --git a/lam/templates/config/confmain.php b/lam/templates/config/confmain.php index 70a0bc22..43b2cac5 100644 --- a/lam/templates/config/confmain.php +++ b/lam/templates/config/confmain.php @@ -57,13 +57,15 @@ if ($_POST['back'] || $_POST['submitconf']){ if ($_POST['language']) $language = $_POST['language']; if ($_POST['scriptpath']) $scriptpath = $_POST['scriptpath']; if ($_POST['samba3']) $samba3 = $_POST['samba3']; + if ($_POST['domainSID']) $domainSID = $_POST['domainSID']; + if ($_POST['scriptpath']) $scriptpath = $_POST['scriptpath']; else $scriptpath = ""; if ($_POST['scriptserver']) $scriptserver = $_POST['scriptserver']; else $scriptserver = ""; session_register('passwd', 'passwd1', 'passwd2', 'serverurl', 'admins', 'suffusers', 'suffgroups', 'suffhosts', 'minUID', 'maxUID', 'minGID', 'maxGID', 'minMach', 'maxMach', 'usrlstattr', 'grplstattr', 'hstlstattr', 'maxlistentries', 'language', - 'scriptpath', 'scriptserver', 'samba3'); + 'scriptpath', 'scriptserver', 'samba3', 'domainSID'); echo(""); } // back to login @@ -135,8 +137,12 @@ echo ("". "get_HostSuffix() . "\">\n"); echo ("" . _("Help") . "\n"); -// new line -echo (" "); +echo (""); +echo (""); +echo ("

"); + +echo ("
" . _("Samba settings") . ""); +echo (""); // Samba version echo (""); echo ("\n"); +// new line +echo (""); + +// Samba domain SID +echo ("". + "\n"); +echo ("\n"); + echo ("
". @@ -145,6 +151,15 @@ if ($conf->get_samba3() == "yes") echo (" else echo ("" . _("Help") . "
 
". + _("Domain SID (Samba 3 only)") . ": get_domainSID() . "\">" . _("Help") . "
"); echo ("
"); echo ("

"); diff --git a/lam/templates/config/confsave.php b/lam/templates/config/confsave.php index 8b2e063d..2d304455 100644 --- a/lam/templates/config/confsave.php +++ b/lam/templates/config/confsave.php @@ -54,6 +54,7 @@ if ($_SESSION['language']) $language = $_SESSION['language']; if ($_SESSION['scriptpath']) $scriptpath = $_SESSION['scriptpath']; if ($_SESSION['scriptserver']) $scriptserver = $_SESSION['scriptserver']; if ($_SESSION['samba3']) $samba3 = $_SESSION['samba3']; +if ($_SESSION['domainSID']) $domainSID = $_SESSION['domainSID']; // check if password is correct // if not: load login page @@ -161,6 +162,12 @@ if (chop($samba3) == "") { exit; } +if ((chop($samba3) == "yes") && (($domainSID == "") || (!$domainSID))) { + echo _("" . _("Samba 3 needs a domain SID!") . ""); + echo ("\n


" . _("Back to preferences...") . ""); + exit; +} + // set new preferences $conf->set_ServerURL($serverurl); $conf->set_Adminstring($admins); @@ -179,6 +186,7 @@ $conf->set_hostlistAttributes($hstlstattr); $conf->set_MaxListEntries($maxlistentries); $conf->set_defaultLanguage($language); $conf->set_samba3($samba3); +$conf->set_domainSID($domainSID); // optional if ($_SESSION['scriptpath']) $conf->set_scriptpath($scriptpath); else $conf->set_scriptpath(""); @@ -228,5 +236,6 @@ unset($_SESSION['language']); unset($_SESSION['scriptpath']); unset($_SESSION['scriptserver']); unset($_SESSION['samba3']); +unset($_SESSION['domainSID']); ?> diff --git a/lam/tests/conf-test.php b/lam/tests/conf-test.php index 290e3bbc..7c556974 100644 --- a/lam/tests/conf-test.php +++ b/lam/tests/conf-test.php @@ -52,6 +52,7 @@ $defaultlanguage = $conf->get_defaultlanguage(); $scriptpath = $conf->get_scriptPath(); $scriptServer = $conf->get_scriptServer(); $samba3 = $conf->get_samba3(); +$domainSID = $conf->get_domainSID(); echo ("done
"); // next we modify them and save lam.conf echo ("Changing preferences..."); @@ -76,6 +77,7 @@ $conf->set_defaultlanguage("de_AT:iso639_de:Deutsch (Oesterreich)"); $conf->set_scriptPath("/var/www/lam/lib/script"); $conf->set_scriptServer("127.0.0.1"); $conf->set_samba3("yes"); +$conf->set_domainSID("S-0-1-22-1234567890-1234567890-1234567890"); $conf->save(); echo ("done
"); // at last all preferences are read from lam.conf and compared @@ -104,6 +106,7 @@ if ($conf->get_defaultlanguage() != "de_AT:iso639_de:Deutsch (Oesterreich)") ech if ($conf->get_scriptPath() != "/var/www/lam/lib/script") echo ("
Saving script path failed!
"); if ($conf->get_scriptServer() != "127.0.0.1") echo ("
Saving script server failed!
"); if ($conf->get_samba3() != "yes") echo ("
Saving samba3 failed!
"); +if ($conf->get_domainSID() != "S-0-1-22-1234567890-1234567890-1234567890") echo ("
Saving domainSID failed!
"); echo ("done
"); // restore old values echo ("Restoring old preferences..."); @@ -128,6 +131,7 @@ $conf->set_defaultLanguage($defaultlanguage); $conf->set_scriptPath($scriptpath); $conf->set_scriptServer($scriptserver); $conf->set_samba3($samba3); +$conf->set_domainSID($domainSID); $conf->save(); echo ("done
"); // finished