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

@ -150,6 +150,11 @@ class Config {
// reloads preferences from config file // reloads preferences from config file
function reload() { 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"; $conffile = substr(__FILE__, 0, strlen(__FILE__) - 15) . "/config/" . $this->file . ".conf";
if (is_file($conffile) == True) { if (is_file($conffile) == True) {
$file = fopen($conffile, "r"); $file = fopen($conffile, "r");
@ -471,23 +476,7 @@ class Config {
// returns an array of string with all admin names // returns an array of string with all admin names
function get_Admins() { function get_Admins() {
return $this->Admins; return explode(";", $this->Adminstring);
}
// 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;
} }
// returns all admin users seperated by semicolons // returns all admin users seperated by semicolons
@ -746,6 +735,12 @@ class Config {
return $this->samba3; 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 // set Samba version: "yes" means 3.x schema, "no" means 2.2.x schema
function set_samba3($value) { function set_samba3($value) {
if (is_string($value) && eregi("^(yes|no)$", $value)) { if (is_string($value) && eregi("^(yes|no)$", $value)) {

View File

@ -123,7 +123,7 @@ class Ldap{
// searches LDAP for a specific user name // searches LDAP for a specific user name
// and returns its DN entry // and returns its DN entry
function search_username($name) { 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 // users have the attribute "posixAccount" or "sambaSamAccount" and uid $name
$filter = "(&(objectClass=sambaSamAccount) (uid=$name))"; $filter = "(&(objectClass=sambaSamAccount) (uid=$name))";
} }

View File

@ -173,7 +173,7 @@ function loadUserProfile($profile) {
continue; continue;
} }
if (substr($line, 0, 12) == "smb_domain: ") { 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)); $dn = chop(substr($line, 12, strlen($line)-12));
// load domain object // load domain object
$dom = new samba3domain(); $dom = new samba3domain();
@ -234,7 +234,7 @@ function loadHostProfile($profile) {
continue; continue;
} }
if (substr($line, 0, 12) == "smb_domain: ") { 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)); $dn = chop(substr($line, 12, strlen($line)-12));
// load domain object // load domain object
$dom = new samba3domain(); $dom = new samba3domain();

View File

@ -168,7 +168,7 @@ echo ("<table border=0>");
// Samba version // Samba version
echo ("<tr><td align=\"right\"><b>". echo ("<tr><td align=\"right\"><b>".
_("Samba 3.x schema") . ": </b></td><td><select name=\"samba3\">\n"); _("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>"); 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"); 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"; echo "<td>\n";
// search available users // search available users
$DN = $_SESSION['config']->get_UserSuffix(); $DN = $_SESSION['config']->get_UserSuffix();
if ($_SESSION['config']->get_samba3() == "yes") { if ($_SESSION['config']->is_samba3()) {
$filter = "(&(objectClass=posixAccount)(objectClass=sambaSamAccount))"; $filter = "(&(objectClass=posixAccount)(objectClass=sambaSamAccount))";
} }
else $filter = "(&(objectClass=posixAccount)(objectClass=sambaAccount))"; else $filter = "(&(objectClass=posixAccount)(objectClass=sambaAccount))";

View File

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

View File

@ -163,7 +163,7 @@ for ($k = 0; $k < sizeof($desc_array); $k++) {
// configure search filter // configure search filter
// Users have the attribute "*" // Users have the attribute "*"
if ($_SESSION['config']->get_samba3() == "yes") { if ($_SESSION['config']->is_samba3()) {
// Samba users have the attribute "sambaSamAccount" and end with "$" // Samba users have the attribute "sambaSamAccount" and end with "$"
$filter = "(&(objectClass=sambaSamAccount) (!(uid=*$))"; $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 (!$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()); $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 // display page to add suffixes or add domain, if needed
if (sizeof($new_suffs) > 0) echo ("<frame src=\"initsuff.php?suffs='" . implode(";", $new_suffs) . if (sizeof($new_suffs) > 0) echo ("<frame src=\"initsuff.php?suffs='" . implode(";", $new_suffs) .
"'\" name=\"mainpart\" frameborder=\"0\" scrolling=\"yes\">\n"); "'\" 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."); $_SESSION['domain_message'] = _("No domains found, please create one.");
echo ("<frame src=\"domain.php?action=new\" name=\"mainpart\" frameborder=\"0\" scrolling=\"yes\">\n"); 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> <td width="100" align="left"><a href="./profedit/profilemain.php" target="mainpart"><?php echo _("Profile Editor"); ?></a></td>
<?php <?php
// Samba 3 has more list views // 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"; 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> <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> <tr>
<?php <?php
// Samba 3 has more list views // 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"; else echo "<td colspan=5>&nbsp;</td>\n";
?> ?>
</tr> </tr>
@ -72,7 +72,7 @@ echo $_SESSION['header'];
<td></td> <td></td>
<?php <?php
// Samba 3 has more list views // 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/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/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"; 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"); echo ("<br>\n");
// domain OUs // domain OUs
if ($_SESSION['config']->get_samba3() == "yes") { if ($_SESSION['config']->is_samba3()) {
echo ("<fieldset><legend><b>" . _("Domains") . "</b></legend>\n"); echo ("<fieldset><legend><b>" . _("Domains") . "</b></legend>\n");
echo ("<table border=0>\n"); echo ("<table border=0>\n");
// new OU // new OU

View File

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