added is_samba3() function

This commit is contained in:
Roland Gruber 2003-09-15 16:24:44 +00:00
parent f2b5b809b2
commit c334ffbaac
12 changed files with 133 additions and 138 deletions

View File

@ -148,112 +148,117 @@ class Config {
$this->reload();
}
// reloads preferences from config file
function reload() {
$conffile = substr(__FILE__, 0, strlen(__FILE__) - 15) . "/config/" . $this->file . ".conf";
if (is_file($conffile) == True) {
$file = fopen($conffile, "r");
while (!feof($file)) {
$line = fgets($file, 1024);
if (($line == "\n")||($line[0] == "#")) continue; // ignore comments
// search keywords
if (strtolower(substr($line, 0, 11)) == "serverurl: ") {
$this->ServerURL = chop(substr($line, 11, strlen($line)-11));
continue;
// reloads preferences from config file
function reload() {
// list of all settings in config file
$settings = array("ServerURL", "Passwd", "Admins", "usersuffix", "groupsuffix", "hostsuffix",
"domainsuffix", "minuid", "maxuid", "mingid", "maxgid", "minmachine", "maxmachine",
"userlistattributes", "grouplistattributes", "hostlistattributes", "maxlistentries",
"defaultlanguage", "scriptpath", "scriptServer", "samba3", "cachetimeout");
$conffile = substr(__FILE__, 0, strlen(__FILE__) - 15) . "/config/" . $this->file . ".conf";
if (is_file($conffile) == True) {
$file = fopen($conffile, "r");
while (!feof($file)) {
$line = fgets($file, 1024);
if (($line == "\n")||($line[0] == "#")) continue; // ignore comments
// search keywords
if (strtolower(substr($line, 0, 11)) == "serverurl: ") {
$this->ServerURL = chop(substr($line, 11, strlen($line)-11));
continue;
}
if (strtolower(substr($line, 0, 8)) == "passwd: ") {
$this->Passwd = chop(substr($line, 8, strlen($line)-8));
continue;
}
if (strtolower(substr($line, 0, 8)) == "admins: ") {
$adminstr = chop(substr($line, 8, strlen($line)-8));
$this->Adminstring = $adminstr;
$this->Admins = explode(";", $adminstr);
continue;
}
if (strtolower(substr($line, 0, 12)) == "usersuffix: ") {
$this->Suff_users = chop(substr($line, 12, strlen($line)-12));
continue;
}
if (strtolower(substr($line, 0, 13)) == "groupsuffix: ") {
$this->Suff_groups = chop(substr($line, 13, strlen($line)-13));
continue;
}
if (strtolower(substr($line, 0, 12)) == "hostsuffix: ") {
$this->Suff_hosts = chop(substr($line, 12, strlen($line)-12));
continue;
}
if (strtolower(substr($line, 0, 14)) == "domainsuffix: ") {
$this->Suff_domains = chop(substr($line, 14, strlen($line)-14));
continue;
}
if (strtolower(substr($line, 0, 8)) == "minuid: ") {
$this->MinUID = chop(substr($line, 8, strlen($line)-8));
continue;
}
if (strtolower(substr($line, 0, 8)) == "maxuid: ") {
$this->MaxUID = chop(substr($line, 8, strlen($line)-8));
continue;
}
if (strtolower(substr($line, 0, 8)) == "mingid: ") {
$this->MinGID = chop(substr($line, 8, strlen($line)-8));
continue;
}
if (strtolower(substr($line, 0, 8)) == "maxgid: ") {
$this->MaxGID = chop(substr($line, 8, strlen($line)-8));
continue;
}
if (strtolower(substr($line, 0, 12)) == "minmachine: ") {
$this->MinMachine = chop(substr($line, 12, strlen($line)-12));
continue;
}
if (strtolower(substr($line, 0, 12)) == "maxmachine: ") {
$this->MaxMachine = chop(substr($line, 12, strlen($line)-12));
continue;
}
if (strtolower(substr($line, 0, 20)) == "userlistattributes: ") {
$this->userlistAttributes = chop(substr($line, 20, strlen($line)-20));
continue;
}
if (strtolower(substr($line, 0, 21)) == "grouplistattributes: ") {
$this->grouplistAttributes = chop(substr($line, 21, strlen($line)-21));
continue;
}
if (strtolower(substr($line, 0, 20)) == "hostlistattributes: ") {
$this->hostlistAttributes = chop(substr($line, 20, strlen($line)-20));
continue;
}
if (strtolower(substr($line, 0, 16)) == "maxlistentries: ") {
$this->maxlistentries = chop(substr($line, 16, strlen($line)-16));
continue;
}
if (strtolower(substr($line, 0, 17)) == "defaultlanguage: ") {
$this->defaultLanguage = chop(substr($line, 17, strlen($line)-17));
continue;
}
if (strtolower(substr($line, 0, 12)) == "scriptpath: ") {
$this->scriptPath = chop(substr($line, 12, strlen($line)-12));
continue;
}
if (strtolower(substr($line, 0, 14)) == "scriptserver: ") {
$this->scriptServer = chop(substr($line, 14, strlen($line)-14));
continue;
}
if (strtolower(substr($line, 0, 8)) == "samba3: ") {
$this->samba3 = strtolower(chop(substr($line, 8, strlen($line)-8)));
continue;
}
if (strtolower(substr($line, 0, 14)) == "cachetimeout: ") {
$this->cache_timeout = chop(substr($line, 14, strlen($line)-14));
continue;
}
}
fclose($file);
}
else {
StatusMessage("ERROR", "", _("Unable to load configuration!") . " (" . $conffile . ")");
}
}
if (strtolower(substr($line, 0, 8)) == "passwd: ") {
$this->Passwd = chop(substr($line, 8, strlen($line)-8));
continue;
}
if (strtolower(substr($line, 0, 8)) == "admins: ") {
$adminstr = chop(substr($line, 8, strlen($line)-8));
$this->Adminstring = $adminstr;
$this->Admins = explode(";", $adminstr);
continue;
}
if (strtolower(substr($line, 0, 12)) == "usersuffix: ") {
$this->Suff_users = chop(substr($line, 12, strlen($line)-12));
continue;
}
if (strtolower(substr($line, 0, 13)) == "groupsuffix: ") {
$this->Suff_groups = chop(substr($line, 13, strlen($line)-13));
continue;
}
if (strtolower(substr($line, 0, 12)) == "hostsuffix: ") {
$this->Suff_hosts = chop(substr($line, 12, strlen($line)-12));
continue;
}
if (strtolower(substr($line, 0, 14)) == "domainsuffix: ") {
$this->Suff_domains = chop(substr($line, 14, strlen($line)-14));
continue;
}
if (strtolower(substr($line, 0, 8)) == "minuid: ") {
$this->MinUID = chop(substr($line, 8, strlen($line)-8));
continue;
}
if (strtolower(substr($line, 0, 8)) == "maxuid: ") {
$this->MaxUID = chop(substr($line, 8, strlen($line)-8));
continue;
}
if (strtolower(substr($line, 0, 8)) == "mingid: ") {
$this->MinGID = chop(substr($line, 8, strlen($line)-8));
continue;
}
if (strtolower(substr($line, 0, 8)) == "maxgid: ") {
$this->MaxGID = chop(substr($line, 8, strlen($line)-8));
continue;
}
if (strtolower(substr($line, 0, 12)) == "minmachine: ") {
$this->MinMachine = chop(substr($line, 12, strlen($line)-12));
continue;
}
if (strtolower(substr($line, 0, 12)) == "maxmachine: ") {
$this->MaxMachine = chop(substr($line, 12, strlen($line)-12));
continue;
}
if (strtolower(substr($line, 0, 20)) == "userlistattributes: ") {
$this->userlistAttributes = chop(substr($line, 20, strlen($line)-20));
continue;
}
if (strtolower(substr($line, 0, 21)) == "grouplistattributes: ") {
$this->grouplistAttributes = chop(substr($line, 21, strlen($line)-21));
continue;
}
if (strtolower(substr($line, 0, 20)) == "hostlistattributes: ") {
$this->hostlistAttributes = chop(substr($line, 20, strlen($line)-20));
continue;
}
if (strtolower(substr($line, 0, 16)) == "maxlistentries: ") {
$this->maxlistentries = chop(substr($line, 16, strlen($line)-16));
continue;
}
if (strtolower(substr($line, 0, 17)) == "defaultlanguage: ") {
$this->defaultLanguage = chop(substr($line, 17, strlen($line)-17));
continue;
}
if (strtolower(substr($line, 0, 12)) == "scriptpath: ") {
$this->scriptPath = chop(substr($line, 12, strlen($line)-12));
continue;
}
if (strtolower(substr($line, 0, 14)) == "scriptserver: ") {
$this->scriptServer = chop(substr($line, 14, strlen($line)-14));
continue;
}
if (strtolower(substr($line, 0, 8)) == "samba3: ") {
$this->samba3 = strtolower(chop(substr($line, 8, strlen($line)-8)));
continue;
}
if (strtolower(substr($line, 0, 14)) == "cachetimeout: ") {
$this->cache_timeout = chop(substr($line, 14, strlen($line)-14));
continue;
}
}
fclose($file);
}
else {
StatusMessage("ERROR", "", _("Unable to load configuration!") . " (" . $conffile . ")");
}
}
// saves preferences to config file
function save() {
@ -471,23 +476,7 @@ class Config {
// returns an array of string with all admin names
function get_Admins() {
return $this->Admins;
}
// needs an array of string containing all admin users
function set_Admins($value) {
if (is_array($value)) { // check if $value is array of strings
$b = true;
for($i = 0; $i < sizeof($value); $i++){
if (is_string($value[$i]) == false) {
$b = false;
break;
}
}
if ($b) $this->Admins = $value;
}
else return false;
return true;
return explode(";", $this->Adminstring);
}
// returns all admin users seperated by semicolons
@ -746,6 +735,12 @@ class Config {
return $this->samba3;
}
// returns true if Samba 3, else false
function is_samba3() {
if ($this->samba3 == "yes") return true;
else return false;
}
// set Samba version: "yes" means 3.x schema, "no" means 2.2.x schema
function set_samba3($value) {
if (is_string($value) && eregi("^(yes|no)$", $value)) {

View File

@ -123,7 +123,7 @@ class Ldap{
// searches LDAP for a specific user name
// and returns its DN entry
function search_username($name) {
if ($this->conf->get_samba3() == "yes") {
if ($this->conf->is_samba3()) {
// users have the attribute "posixAccount" or "sambaSamAccount" and uid $name
$filter = "(&(objectClass=sambaSamAccount) (uid=$name))";
}

View File

@ -173,7 +173,7 @@ function loadUserProfile($profile) {
continue;
}
if (substr($line, 0, 12) == "smb_domain: ") {
if ($_SESSION['config']->get_samba3() == "yes") {
if ($_SESSION['config']->is_samba3()) {
$dn = chop(substr($line, 12, strlen($line)-12));
// load domain object
$dom = new samba3domain();
@ -234,7 +234,7 @@ function loadHostProfile($profile) {
continue;
}
if (substr($line, 0, 12) == "smb_domain: ") {
if ($_SESSION['config']->get_samba3() == "yes") {
if ($_SESSION['config']->is_samba3()) {
$dn = chop(substr($line, 12, strlen($line)-12));
// load domain object
$dom = new samba3domain();

View File

@ -168,7 +168,7 @@ echo ("<table border=0>");
// Samba version
echo ("<tr><td align=\"right\"><b>".
_("Samba 3.x schema") . ": </b></td><td><select name=\"samba3\">\n");
if ($conf->get_samba3() == "yes") echo ("<option>yes</option><option>no</option></select></td>");
if ($conf->is_samba3()) echo ("<option>yes</option><option>no</option></select></td>");
else echo ("<option>no</option><option>yes</option></select></td>");
echo ("<td><a href=\"../help.php?HelpNumber=213\" target=\"lamhelp\">" . _("Help") . "</a></td></tr>\n");

View File

@ -171,7 +171,7 @@ if ($sr) {
echo "<td>\n";
// search available users
$DN = $_SESSION['config']->get_UserSuffix();
if ($_SESSION['config']->get_samba3() == "yes") {
if ($_SESSION['config']->is_samba3()) {
$filter = "(&(objectClass=posixAccount)(objectClass=sambaSamAccount))";
}
else $filter = "(&(objectClass=posixAccount)(objectClass=sambaAccount))";

View File

@ -112,7 +112,7 @@ for ($k = 0; $k < sizeof($desc_array); $k++) {
if (! $_GET['norefresh']) {
// configure search filter
if ($_SESSION['config']->get_samba3() == "yes") {
if ($_SESSION['config']->is_samba3()) {
// Samba hosts have the attribute "sambaSamAccount" and end with "$"
$filter = "(&(objectClass=sambaSamAccount) (uid=*$)";
}

View File

@ -163,7 +163,7 @@ for ($k = 0; $k < sizeof($desc_array); $k++) {
// configure search filter
// Users have the attribute "*"
if ($_SESSION['config']->get_samba3() == "yes") {
if ($_SESSION['config']->is_samba3()) {
// Samba users have the attribute "sambaSamAccount" and end with "$"
$filter = "(&(objectClass=sambaSamAccount) (!(uid=*$))";
}

View File

@ -52,7 +52,7 @@ if ($conf->Suff_map && ($conf->Suff_map != "")) {
if (!$res) $new_suffs[] = $conf->Suff_map;
}
if ($_SESSION['config']->get_samba3() == "yes") {
if ($_SESSION['config']->is_samba3()) {
$doms = $_SESSION['ldap']->search_domains($_SESSION['config']->get_domainSuffix());
}
@ -67,7 +67,7 @@ echo ("<frame src=\"./main_header.php\" name=\"head\" frameborder=\"0\" scrollin
// display page to add suffixes or add domain, if needed
if (sizeof($new_suffs) > 0) echo ("<frame src=\"initsuff.php?suffs='" . implode(";", $new_suffs) .
"'\" name=\"mainpart\" frameborder=\"0\" scrolling=\"yes\">\n");
elseif (($_SESSION['config']->get_samba3() == "yes") && (sizeof($doms) < 1)) {
elseif (($_SESSION['config']->is_samba3()) && (sizeof($doms) < 1)) {
$_SESSION['domain_message'] = _("No domains found, please create one.");
echo ("<frame src=\"domain.php?action=new\" name=\"mainpart\" frameborder=\"0\" scrolling=\"yes\">\n");
}

View File

@ -47,7 +47,7 @@ echo $_SESSION['header'];
<td width="100" align="left"><a href="./profedit/profilemain.php" target="mainpart"><?php echo _("Profile Editor"); ?></a></td>
<?php
// Samba 3 has more list views
if ($_SESSION['config']->get_samba3() == "yes") echo "<td rowspan=3 colspan=4 align=\"center\">\n";
if ($_SESSION['config']->is_samba3()) echo "<td rowspan=3 colspan=4 align=\"center\">\n";
else echo "<td rowspan=3 colspan=3 align=\"center\">\n";
?>
<a href="http://lam.sf.net" target="new_window"><img src="../graphics/banner.jpg" border=1 alt="LDAP Account Manager"></a>
@ -64,7 +64,7 @@ echo $_SESSION['header'];
<tr>
<?php
// Samba 3 has more list views
if ($_SESSION['config']->get_samba3() == "yes") echo "<td colspan=6>&nbsp;</td>\n";
if ($_SESSION['config']->is_samba3()) echo "<td colspan=6>&nbsp;</td>\n";
else echo "<td colspan=5>&nbsp;</td>\n";
?>
</tr>
@ -72,7 +72,7 @@ echo $_SESSION['header'];
<td></td>
<?php
// Samba 3 has more list views
if ($_SESSION['config']->get_samba3() == "yes") {
if ($_SESSION['config']->is_samba3()) {
echo '<td width="120" align="center"><a href="./lists/listdomains.php" target="mainpart">' . _("Domains") . '</a></td>' . "\n";
echo '<td width="120" align="center"><a href="./lists/listusers.php" target="mainpart">' . _("Users") . '</a></td>' . "\n";
echo '<td width="120" align="center"><a href="./lists/listgroups.php" target="mainpart">' . _("Groups") . '</a></td>' . "\n";

View File

@ -438,7 +438,7 @@ function display_main() {
echo ("<br>\n");
// domain OUs
if ($_SESSION['config']->get_samba3() == "yes") {
if ($_SESSION['config']->is_samba3()) {
echo ("<fieldset><legend><b>" . _("Domains") . "</b></legend>\n");
echo ("<table border=0>\n");
// new OU

View File

@ -80,7 +80,7 @@ echo ("<tr><td>&nbsp</td><td>&nbsp</td><td>&nbsp</td></tr>\n");
// domain
echo ("<tr>\n");
echo ("<td align=\"right\"><b>" . _("Domain") . ": </b></td>\n");
if ($_SESSION['config']->get_samba3() == "yes") {
if ($_SESSION['config']->is_samba3()) {
echo "<td><select name=\"smb_domain\">\n";
$doms = $_SESSION['ldap']->search_domains($_SESSION['config']->get_DomainSuffix());
for ($i = 0; $i < sizeof($doms); $i++) {

View File

@ -327,7 +327,7 @@ echo ("<tr><td>&nbsp</td><td>&nbsp</td><td>&nbsp</td></tr>\n");
// domain
echo ("<tr>\n");
echo ("<td align=\"right\"><b>" . _("Domain") . ": </b></td>\n");
if ($_SESSION['config']->get_samba3() == "yes") {
if ($_SESSION['config']->is_samba3()) {
echo "<td><select name=\"smb_domain\">\n";
$doms = $_SESSION['ldap']->search_domains($_SESSION['config']->get_DomainSuffix());
for ($i = 0; $i < sizeof($doms); $i++) {