added suffixes for users, groups and hosts

This commit is contained in:
Roland Gruber 2003-03-05 18:38:19 +00:00
parent 17e8722a81
commit 8cb06bcf67
5 changed files with 124 additions and 16 deletions

View File

@ -25,21 +25,36 @@ $Id$
// Config supplies access to the configuration data.
class Config {
// string: can be "True" or "False"
// use SSL-connection?
var $SSL;
// string: hostname
var $Host;
// string: port number
var $Port;
// array of strings: users with admin rights
var $Admins;
// string: password to edit preferences
var $Passwd;
// single line with the names of all admin users
var $Adminstring;
// suffix for users
var $suff_users;
// suffix for groups
var $suff_groups;
// suffix for Samba hosts
var $suff_hosts;
// constructor, loads preferences from ../lam.conf
function Config() {
$this->reload();
@ -75,6 +90,18 @@ class Config {
$this->Admins = explode(";", $adminstr);
continue;
}
if (substr($line, 0, 12) == "usersuffix: ") {
$this->suff_users = chop(substr($line, 12, strlen($line)-12));
continue;
}
if (substr($line, 0, 13) == "groupsuffix: ") {
$this->suff_groups = chop(substr($line, 13, strlen($line)-13));
continue;
}
if (substr($line, 0, 12) == "hostsuffix: ") {
$this->suff_hosts = chop(substr($line, 12, strlen($line)-12));
continue;
}
}
fclose($file);
}
@ -87,7 +114,7 @@ class Config {
function save() {
$conffile = "../lam.conf";
if (is_file($conffile) == True) {
$save_ssl = $save_host = $save_port = $save_passwd = $save_admins = False;
$save_ssl = $save_host = $save_port = $save_passwd = $save_admins = $save_suffusr = $save_suffgrp = $save_suffhst = False;
$file = fopen($conffile, "r");
$file_array = array();
while (!feof($file)) {
@ -121,15 +148,36 @@ class Config {
$save_admins = True;
continue;
}
if (substr($file_array[$i], 0, 12) == "usersuffix: ") {
$file_array[$i] = "usersuffix: " . $this->suff_users . "\n";
$save_suffusr = True;
continue;
}
if (substr($file_array[$i], 0, 13) == "groupsuffix: ") {
$file_array[$i] = "groupsuffix: " . $this->suff_groups . "\n";
$save_suffgrp = True;
continue;
}
if (substr($file_array[$i], 0, 12) == "hostsuffix: ") {
$file_array[$i] = "hostsuffix: " . $this->suff_hosts . "\n";
$save_suffhst = True;
continue;
}
}
// check if we have to add new entries
if (!$save_ssl == True) array_push($file_array, "# use SSL to connect, can be True or False\n" . "ssl: " . $this->SSL);
if (!$save_host == True) array_push($file_array, "# hostname of LDAP server (e.g localhost)\n" . "ssl: " . $this->Host);
if (!$save_port == True) array_push($file_array, "# portnumber of LDAP server (default 389)\n" . "ssl: " . $this->Port);
if (!$save_passwd == True) array_push($file_array, "# password to change these preferences via webfrontend\n" . "ssl: " . $this->Passwd);
if (!$save_admins == True) array_push($file_array, "# list of users who are allowed to use LDAP Account Manager\n
# names have to be seperated by semicolons\n
# e.g. admins: cn=admin,dc=yourdomain,dc=org;cn=root,dc=yourdomain,dc=org\n" . "ssl: " . $this->Admins);
// check if we have to add new entries (e.g. if user upgraded LAM)
if (!$save_ssl == True) array_push($file_array, "\n# use SSL to connect, can be True or False\n" . "ssl: " . $this->SSL);
if (!$save_host == True) array_push($file_array, "\n# hostname of LDAP server (e.g localhost)\n" . "host: " . $this->Host);
if (!$save_port == True) array_push($file_array, "\n# portnumber of LDAP server (default 389)\n" . "port: " . $this->Port);
if (!$save_passwd == True) array_push($file_array, "\n# password to change these preferences via webfrontend\n" . "passwd: " . $this->Passwd);
if (!$save_admins == True) array_push($file_array, "\n# list of users who are allowed to use LDAP Account Manager\n" .
"# names have to be seperated by semicolons\n" .
"# e.g. admins: cn=admin,dc=yourdomain,dc=org;cn=root,dc=yourdomain,dc=org\n" . "admins: " . $this->Admins);
if (!$save_suffusr == True) array_push($file_array, "\n# suffix of users\n" .
"# e.g. ou=People,dc=yourdomain,dc=org\n" . "usersuffix: " . $this->suff_users);
if (!$save_suffgrp == True) array_push($file_array, "\n# suffix of groups\n" .
"# e.g. ou=Groups,dc=yourdomain,dc=org\n" . "groupsuffix: " . $this->suff_groups);
if (!$save_suffhst == True) array_push($file_array, "\n# suffix of hosts\n" .
"# e.g. ou=machines,dc=yourdomain,dc=org\n" . "hostsuffix: " . $this->suff_hosts);
$file = fopen($conffile, "w");
for ($i = 0; $i < sizeof($file_array); $i++) fputs($file, $file_array[$i]);
fclose($file);
@ -141,7 +189,10 @@ class Config {
echo _("<b>SSL: </b>" ) . $this->SSL . "</br>";
echo _("<b>Host: </b>") . $this->Host . "</br>";
echo _("<b>Port: </b>") . $this->Port . "</br>";
echo _("<b>Admins: </b>") . $this->Adminstring;
echo _("<b>Admins: </b>") . $this->Adminstring . "</br>";
echo _("<b>UserSuffix: </b>") . $this->suff_users . "</br>";
echo _("<b>GroupSuffix: </b>") . $this->suff_groups . "</br>";
echo _("<b>HostSuffix: </b>") . $this->suff_hosts;
}
function get_SSL() {
@ -209,6 +260,33 @@ class Config {
else echo _("Config->set_Passwd failed!");
}
function get_UserSuffix() {
return $this->suff_users;
}
function set_UserSuffix($value) {
if (is_string($value)) $this->suff_users = $value;
else echo _("Config->set_UserSuffix failed!");
}
function get_GroupSuffix() {
return $this->suff_groups;
}
function set_GroupSuffix($value) {
if (is_string($value)) $this->suff_groups = $value;
else echo _("Config->set_GroupSuffix failed!");
}
function get_HostSuffix() {
return $this->suff_hosts;
}
function set_HostSuffix($value) {
if (is_string($value)) $this->suff_hosts = $value;
else echo _("Config->set_HostSuffix failed!");
}
}
?>
?>

View File

@ -33,7 +33,7 @@ $Id$
</title>
</head>
<body>
<br><b><big><big><p align="center"> LDAP Account Manager</b></big></big></p><br><br>
<p align="center"><img src="../graphics/banner.jpg" border=1></p><hr><br><br>
<b><p align="center"> <? echo _("Password to enter preferences:"); ?> </b></p>
<form action="confmain.php" method="post">
<p align="center"><input type="password" name="passwd">

View File

@ -43,7 +43,7 @@ echo ("<head>\n");
echo ("<title>" . _("LDAP Account Manager Configuration") . "</title>\n");
echo ("</head>\n");
echo ("<body>\n");
echo ("<br><b><big><big><p align=\"center\"> LDAP Account Manager</b></big></big></p><br><br>\n");
echo ("<p align=\"center\"><img src=\"../graphics/banner.jpg\" border=1></p><hr><br><br>\n");
echo ("<form action=\"confsave.php\" method=\"post\">\n");
echo ("<p align=\"center\"><table border=\"0\">");
echo ("<tr><th><p align=\"right\"><b>" . _("Hostname") . ": </b></th> <th><p align=\"left\"><input type=\"text\" name=\"host\" value=\"" . $conf->get_Host() . "\"></th></tr>\n");
@ -52,7 +52,14 @@ echo _("<th><p align=\"left\">Default is 389, use 636 for SSL connections</th></
if ($conf->get_SSL() == "True") echo ("<tr><th><p align=\"right\"><b>" . _("Use SSL") . ": </b></th> <th><p align=\"left\"><input type=\"checkbox\" name=\"ssl\" checked></th></tr>\n");
else echo ("<tr><th><p align=\"right\"><b>" . _("Use SSL") . ": </b></th> <th><p align=\"left\"><input type=\"checkbox\" name=\"ssl\"></th></tr>\n");
echo ("<tr><th><p align=\"right\"><b>" . _("List of valid users") . ": </b></th> <th><input size=50 type=\"text\" name=\"admins\" value=\"" . $conf->get_Adminstring() . "\"></th>\n");
echo _("<th><p align=\"left\">Usernames must be seperated by semicolons<br>(e.g. cn=admin,dc=yourcompany,dc=com ; uid=root,ou=people,dc=yourcompany,cd=com)</th></tr>\n");
echo _("<th><p align=\"left\">Usernames must be seperated by semicolons<br>(e.g. cn=admin,dc=yourcompany,dc=com ; uid=root,ou=people,dc=yourcompany,dc=com)</th></tr>\n");
echo ("<tr><th>&nbsp</th></tr>");
echo ("<tr><th><p align=\"right\"><b>" . _("UserSuffix") . ": </b></th> <th><input size=50 type=\"text\" name=\"suffusers\" value=\"" . $conf->get_UserSuffix() . "\"></th>\n");
echo _("<th><p align=\"left\">This is the suffix from where to search for users.<br>(e.g. ou=People,dc=yourcompany,dc=com)</th></tr>\n");
echo ("<tr><th><p align=\"right\"><b>" . _("GroupSuffix") . ": </b></th> <th><input size=50 type=\"text\" name=\"suffgroups\" value=\"" . $conf->get_GroupSuffix() . "\"></th>\n");
echo _("<th><p align=\"left\">This is the suffix from where to search for groups.<br>(e.g. ou=group,dc=yourcompany,dc=com)</th></tr>\n");
echo ("<tr><th><p align=\"right\"><b>" . _("HostSuffix") . ": </b></th> <th><input size=50 type=\"text\" name=\"suffhosts\" value=\"" . $conf->get_HostSuffix() . "\"></th>\n");
echo _("<th><p align=\"left\">This is the suffix from where to search for Samba hosts.<br>(e.g. ou=machines,dc=yourcompany,dc=com)</th></tr>\n");
echo ("<tr><th>&nbsp</th></tr>");
echo ("<tr><th><p align=\"right\"><b>" . _("New Password") . ": </b></th> <th><p align=\"left\"><input type=\"password\" name=\"pass1\"></th></tr>\n");
echo ("<tr><th><p align=\"right\"><b>" . _("Reenter Password") . ": </b></th> <th><p align=\"left\"><input type=\"password\" name=\"pass2\"></th></tr>\n");

View File

@ -46,6 +46,14 @@ if (chop($admins) == "") {
echo _("<b>" . _("List of admin users is empty!") . "</b>");
exit;
}
if (chop($suffusers) == "") {
echo _("<b>" . _("UserSuffix is empty!") . "</b>");
exit;
}
if (chop($suffgroups) == "") {
echo _("<b>" . _("UserSuffix is empty!") . "</b>");
exit;
}
// set new preferences
$conf->set_Host($host);
@ -53,8 +61,11 @@ $conf->set_Port($port);
$conf->set_Adminstring($admins);
if ($ssl == "on") $conf->set_SSL("True");
else $conf->set_SSL("False");
$conf->set_UserSuffix($suffusers);
$conf->set_GroupSuffix($suffgroups);
$conf->set_HostSuffix($suffhosts);
echo ("<br><b><big><big><p align=\"center\"> LDAP Account Manager</b></big></big></p><br><br>");
echo ("<p align=\"center\"><img src=\"../graphics/banner.jpg\"></p><hr><br><br>");
// check if password was changed
@ -70,4 +81,5 @@ if ($pass1 != "") {
$conf->save();
echo ("<b>" . _("Saving the following settings:") . "</b><br><br>");
$conf->printconf();
?>
?>

View File

@ -17,3 +17,14 @@ admins: cn=admin,o=test,c=de;uid=testuser,o=test,c=de
# password to change these preferences via webfrontend
passwd: lam
# suffix of users
# e.g. ou=People,dc=yourdomain,dc=org
usersuffix: ou=People,o=test,c=de
# suffix of groups
# e.g. ou=Groups,dc=yourdomain,dc=org
groupsuffix: ou=group,o=test,c=de
# suffix of hosts
# e.g. ou=machines,dc=yourdomain,dc=org
hostsuffix: ou=machines,o=test,c=de