removed shell list and default shell

merged host+port+ssl to serverURL
This commit is contained in:
Roland Gruber 2003-04-18 15:50:01 +00:00
parent cc06a1d7eb
commit c61f45bf3e
5 changed files with 33 additions and 168 deletions

View File

@ -28,15 +28,8 @@ $Id$
class Config {
// string: can be "True" or "False"
// use SSL-connection?
var $SSL;
// string: hostname
var $Host;
// string: port number
var $Port;
// server address (e.g. ldap://127.0.0.1:389)
var $ServerURL;
// array of strings: users with admin rights
var $Admins;
@ -69,10 +62,6 @@ class Config {
var $grouplistAttributes;
var $hostlistAttributes;
// default shell and list of possible shells
var $DefaultShell;
var $ShellList;
// constructor, loads preferences from ../lam.conf
function Config() {
$this->reload();
@ -87,16 +76,8 @@ class Config {
$line = fgets($file, 1024);
if (($line == "\n")||($line[0] == "#")) continue; // ignore comments
// search keywords
if (substr($line, 0, 5) == "ssl: ") {
$this->SSL = chop(substr($line, 5, strlen($line)-5));
continue;
}
if (substr($line, 0, 6) == "host: ") {
$this->Host = chop(substr($line, 6, strlen($line)-6));
continue;
}
if (substr($line, 0, 6) == "port: ") {
$this->Port = chop(substr($line, 6, strlen($line)-6));
if (substr($line, 0, 11) == "serverURL: ") {
$this->ServerURL = chop(substr($line, 11, strlen($line)-11));
continue;
}
if (substr($line, 0, 8) == "passwd: ") {
@ -145,14 +126,6 @@ class Config {
$this->MaxMachine = chop(substr($line, 12, strlen($line)-12));
continue;
}
if (substr($line, 0, 14) == "defaultShell: ") {
$this->DefaultShell = chop(substr($line, 14, strlen($line)-14));
continue;
}
if (substr($line, 0, 11) == "shellList: ") {
$this->ShellList = chop(substr($line, 11, strlen($line)-11));
continue;
}
if (substr($line, 0, 20) == "userlistAttributes: ") {
$this->userlistAttributes = chop(substr($line, 20, strlen($line)-20));
continue;
@ -178,9 +151,9 @@ class Config {
$conffile = "../lam.conf";
if (is_file($conffile) == True) {
// booleans to check if value was already saved
$save_ssl = $save_host = $save_port = $save_passwd = $save_admins = $save_suffusr = $save_suffgrp = $save_suffhst =
$save_minUID = $save_maxUID = $save_minGID = $save_maxGID = $save_minMach = $save_maxMach = $save_defShell =
$save_shellList = $save_usrlstatrr = $save_grplstatrr = $save_hstlstatrr = False;
$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 = False;
$file = fopen($conffile, "r");
$file_array = array();
while (!feof($file)) {
@ -190,19 +163,9 @@ class Config {
for ($i = 0; $i < sizeof($file_array); $i++) {
if (($file_array[$i] == "\n")||($file_array[$i][0] == "#")) continue; // ignore comments
// search for keywords
if (substr($file_array[$i], 0, 5) == "ssl: ") {
$file_array[$i] = "ssl: " . $this->SSL . "\n";
$save_ssl = True;
continue;
}
if (substr($file_array[$i], 0, 6) == "host: ") {
$file_array[$i] = "host: " . $this->Host . "\n";
$save_host = True;
continue;
}
if (substr($file_array[$i], 0, 6) == "port: ") {
$file_array[$i] = "port: " . $this->Port . "\n";
$save_port = True;
if (substr($file_array[$i], 0, 11) == "serverURL: ") {
$file_array[$i] = "serverURL: " . $this->ServerURL . "\n";
$save_serverURL = True;
continue;
}
if (substr($file_array[$i], 0, 8) == "passwd: ") {
@ -260,16 +223,6 @@ class Config {
$save_maxMach = True;
continue;
}
if (substr($file_array[$i], 0, 14) == "defaultShell: ") {
$file_array[$i] = "defaultShell: " . $this->DefaultShell . "\n";
$save_defShell = True;
continue;
}
if (substr($file_array[$i], 0, 11) == "shellList: ") {
$file_array[$i] = "shellList: " . $this->ShellList . "\n";
$save_shellList = True;
continue;
}
if (substr($file_array[$i], 0, 20) == "userlistAttributes: ") {
$file_array[$i] = "userlistAttributes: " . $this->userlistAttributes . "\n";
$save_usrlstattr = True;
@ -287,9 +240,7 @@ class Config {
}
}
// check if we have to add new entries (e.g. if user upgraded LAM and has an old lam.conf)
if (!$save_ssl == True) array_push($file_array, "\n\n# use SSL to connect, can be True or False\n" . "ssl: " . $this->SSL);
if (!$save_host == True) array_push($file_array, "\n\n# hostname of LDAP server (e.g localhost)\n" . "host: " . $this->Host);
if (!$save_port == True) array_push($file_array, "\n\n# portnumber of LDAP server (default 389)\n" . "port: " . $this->Port);
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);
if (!$save_passwd == True) array_push($file_array, "\n\n# password to change these preferences via webfrontend\n" . "passwd: " . $this->Passwd);
if (!$save_admins == True) array_push($file_array, "\n\n# list of users who are allowed to use LDAP Account Manager\n" .
"# names have to be seperated by semicolons\n" .
@ -306,8 +257,6 @@ class Config {
if (!$save_maxGID == True) array_push($file_array, "\n\n# maximum GID number\n" . "maxGID: " . $this->MaxGID);
if (!$save_minMach == True) array_push($file_array, "\n\n# minimum UID number for Samba hosts\n" . "minMachine: " . $this->MinMachine);
if (!$save_maxMach == True) array_push($file_array, "\n\n# maximum UID number for Samba hosts\n" . "maxMachine: " . $this->MaxMachine);
if (!$save_defShell == True) array_push($file_array, "\n\n# default shell when creating new user\n" . "defaultShell: " . $this->DefaultShell);
if (!$save_shellList == True) array_push($file_array, "\n\n# list of possible shells\n# values have to be seperated by semicolons\n" . "shellList: " . $this->ShellList);
if (!$save_usrlstattr == True) array_push($file_array, "\n\n# list of attributes to show in user list\n# entries can either be predefined values (e.g. '#cn' or '#uid')" .
"\n# or individual ones (e.g. 'uid:User ID' or 'host:Host Name')\n# values have to be seperated by semicolons\n" . "userlistAttributes: " . $this->userlistAttributes);
if (!$save_grplstattr == True) array_push($file_array, "\n\n# list of attributes to show in group list\n# entries can either be predefined values (e.g. '#cn' or '#gidNumber')" .
@ -328,9 +277,7 @@ class Config {
// prints current preferences
function printconf() {
echo _("<b>SSL: </b>" ) . $this->SSL . "<br>";
echo _("<b>Host: </b>") . $this->Host . "<br>";
echo _("<b>Port: </b>") . $this->Port . "<br>";
echo _("<b>ServerURL: </b>") . $this->ServerURL . "<br>";
echo _("<b>Admins: </b>") . $this->Adminstring . "<br>";
echo _("<b>UserSuffix: </b>") . $this->Suff_users . "<br>";
echo _("<b>GroupSuffix: </b>") . $this->Suff_groups . "<br>";
@ -343,44 +290,20 @@ class Config {
echo _("<b>maxMachine: </b>") . $this->MaxMachine . "<br>";
echo _("<b>userlistAttributes: </b>") . $this->userlistAttributes . "<br>";
echo _("<b>grouplistAttributes: </b>") . $this->grouplistAttributes . "<br>";
echo _("<b>hostlistAttributes: </b>") . $this->hostlistAttributes . "<br>";
echo _("<b>Default Shell: </b>") . $this->DefaultShell . "<br>";
echo _("<b>Shell list: </b>") . $this->ShellList;
echo _("<b>hostlistAttributes: </b>") . $this->hostlistAttributes;
}
// functions to read/write preferences
// returns a string that can be "True" or "False"
function get_SSL() {
return $this->SSL;
// returns the server address as string
function get_ServerURL() {
return $this->ServerURL;
}
// accepts only strings that are either "True" or "False"
function set_SSL($value) {
if (($value == "True") || ($value == "False")) $this->SSL = $value;
else echo _("Config->set_SSL failed!");
}
// returns the hostname
function get_Host() {
return $this->Host;
}
// sets the hostname
function set_Host($value) {
if (is_string($value)) $this->Host = $value;
else echo _("Config->set_Host failed!");
}
// returns the port number as string
function get_Port() {
return $this->Port;
}
// sets the portnumber
function set_Port($value) {
if (is_numeric($value)) $this->Port = $value;
else echo _("Config->set_Port failed!");
// sets the server address
function set_ServerURL($value) {
if (is_string($value)) $this->ServerURL = $value;
else echo _("Config->set_ServerURL failed!");
}
// returns an array of string with all admin names
@ -527,28 +450,6 @@ class Config {
else echo _("Config->set_maxMachine failed!");
}
// returns the default shell to use when creating new users
function get_defaultShell() {
return $this->DefaultShell;
}
// sets the default shell to use when creating new users
function set_defaultShell($value) {
if (is_string($value)) $this->DefaultShell = $value;
else echo _("Config->set_shellList failed!");
}
// returns a list of possible shells when creating new users
function get_shellList() {
return $this->ShellList;
}
// sets the list of possible shells when creating new users
function set_shellList($value) {
if (is_string($value)) $this->ShellList = $value;
else echo _("Config->set_shellList failed!");
}
// returns the list of attributes to show in user list
function get_userlistAttributes() {
return $this->userlistAttributes;

View File

@ -52,13 +52,8 @@ echo ("<body>\n");
echo ("<p align=\"center\"><a href=\"http://lam.sf.net\" target=\"new_window\"><img src=\"../graphics/banner.jpg\" border=1 alt=\"LDAP Account Manager\"></a></p><hr><br><br>\n");
echo ("<form action=\"confsave.php\" method=\"post\">\n");
echo ("<table align=\"center\" border=\"0\">");
echo ("<tr><td width=\"20%\"><p align=\"right\"><b>" . _("Hostname") . ": </b></p></td> <td width=\"30%\"><p align=\"left\"><input type=\"text\" name=\"host\" value=\"" . $conf->get_Host() . "\"></td>\n");
echo ("<td width=\"50%\"><p align=\"left\">" . _("Hostname of LDAP server") . "</p></td></tr>\n");
echo ("<tr><td><p align=\"right\"><b>" . _("Portnumber") . ": </b></p></td> <td><p align=\"left\"><input type=\"text\" size=5 name=\"port\" value=\"" . $conf->get_Port() . "\"></td>\n");
echo _("<td><p align=\"left\">Default is 389, use 636 for SSL connections</p></td></tr>\n");
if ($conf->get_SSL() == "True") echo ("<tr><td><p align=\"right\"><b>" . _("Use SSL") . ": </b></p></td> <td><p align=\"left\"><input type=\"checkbox\" name=\"ssl\" checked></td>\n");
else echo ("<tr><td><p align=\"right\"><b>" . _("Use SSL") . ": </b></p></td> <td><p align=\"left\"><input type=\"checkbox\" name=\"ssl\"></td>\n");
echo ("<td><p align=\"left\">" . _("Check if your server supports secure connections.") . "</p></td></tr>\n");
echo ("<tr><td width=\"20%\"><p align=\"right\"><b>" . _("Server Address") . ": </b></p></td> <td width=\"30%\"><p align=\"left\"><input size=50 type=\"text\" name=\"serverurl\" value=\"" . $conf->get_ServerURL() . "\"></td>\n");
echo ("<td width=\"50%\"><p align=\"left\">" . _("Server Address of LDAP server (e.g. ldap://localhost:389 or ldaps://localhost:636)") . "</p></td></tr>\n");
echo ("<tr><td>&nbsp</td></tr>");
echo ("<tr><td><p align=\"right\"><b>" . _("List of valid users") . ": </b></p></td> <td><input size=50 type=\"text\" name=\"admins\" value=\"" . $conf->get_Adminstring() . "\"></td>\n");
echo ("<td><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)") . "</p></td></tr>\n");
@ -85,11 +80,6 @@ echo ("<td rowspan=3><p>" . _("This is the list of attributes to show in the lis
. "</p></td></tr>");
echo ("<tr><td><p align=\"right\"><b>" . _("Attributes in Group List:") . "</b></p></td><td><input size=50 type=\"text\" name=\"grplstattr\" value=\"" . $conf->get_grouplistAttributes() . "\"></td></tr>");
echo ("<tr><td><p align=\"right\"><b>" . _("Attributes in Host List:") . "</b></p></td><td><input size=50 type=\"text\" name=\"hstlstattr\" value=\"" . $conf->get_hostlistAttributes() . "\"></td></tr>");
echo ("<tr><td>&nbsp</td></tr>");
echo ("<tr><td><p align=\"right\"><b>" . _("Default shell") . ": </b></p></td> <td><p align=\"left\"><input type=\"text\" name=\"defShell\" value=\"" . $conf->get_defaultShell() . "\"></td>\n");
echo ("<td><p align=\"left\">" . _("Default shell when creating new users.") . "</p></td></tr>\n");
echo ("<tr><td><p align=\"right\"><b>" . _("Shell list") . ": </b></p></td> <td><p align=\"left\"><input type=\"text\" size=50 name=\"shellList\" value=\"" . $conf->get_shellList() . "\"></td>\n");
echo ("<td><p align=\"left\">" . _("List of possible shells when creating new users. <br> The entries have to be separated by semicolons.") . "</p></td></tr>\n");
echo ("</table>\n");
echo ("<p>&nbsp</p>\n");
echo ("<table align=\"left\" border=\"0\">");

View File

@ -41,13 +41,8 @@ if ($passwd != $conf->get_Passwd()) {
echo ("<p align=\"center\"><a href=\"http://lam.sf.net\" target=\"new_window\"><img src=\"../graphics/banner.jpg\" border=1></a></p><hr><br><br>");
// check new preferences
if (chop($host) == "") {
echo _("<font color=\"red\"><b>" . _("Hostname is empty!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (chop($port) == "") {
echo _("<font color=\"red\"><b>" . _("Portnumber is empty!") . "</b></font>");
if (chop($serverurl) == "") {
echo _("<font color=\"red\"><b>" . _("Server Address is empty!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
@ -96,16 +91,6 @@ if (chop($maxMach) == "") {
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (chop($defShell) == "") {
echo _("<font color=\"red\"><b>" . _("Default shell is empty!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (chop($shellList) == "") {
echo _("<font color=\"red\"><b>" . _("Shell list is empty!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (chop($usrlstattr) == "") {
echo _("<font color=\"red\"><b>" . _("No attributes in user list!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
@ -123,11 +108,8 @@ if (chop($hstlstattr) == "") {
}
// set new preferences
$conf->set_Host($host);
$conf->set_Port($port);
$conf->set_ServerURL($serverurl);
$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);
@ -137,8 +119,6 @@ $conf->set_minGID($minGID);
$conf->set_maxGID($maxGID);
$conf->set_minMachine($minMach);
$conf->set_maxMachine($maxMach);
$conf->set_defaultShell($defShell);
$conf->set_shellList($shellList);
$conf->set_userlistAttributes($usrlstattr);
$conf->set_grouplistAttributes($grplstattr);
$conf->set_hostlistAttributes($hstlstattr);

View File

@ -1,13 +1,7 @@
# LDAP Account Manager configuration
# hostname of LDAP server (e.g localhost)
host: localhost
# portnumber of LDAP server (default 389)
port: 389
# use SSL to connect, can be True or False
ssl: False
# server address (e.g. ldap://localhost:389 or ldaps://localhost:636)
serverURL: ldap://localhost:389
# list of users who are allowed to use LDAP Account Manager
# names have to be seperated by semicolons
@ -19,7 +13,7 @@ passwd: lam
# suffix of users
# e.g. ou=People,dc=yourdomain,dc=org
usersuffix: ou=People,o=test,c=de
usersuffix: o=test,c=de
# suffix of groups
# e.g. ou=Groups,dc=yourdomain,dc=org

View File

@ -103,8 +103,8 @@ class Ldap{
}
// save password und username encrypted
$this->encrypt($user, $passwd);
if ($this->conf->get_SSL() == "True") $this->server = @ldap_connect("ldaps://" . $this->conf->get_Host(), $this->conf->get_Port());
else $this->server = @ldap_connect("ldap://" . $this->conf->get_Host(), $this->conf->get_Port());
$this->server = @ldap_connect($this->conf->get_ServerURL());
if ($this->server) {
// use LDAPv3
ldap_set_option($this->server, LDAP_OPT_PROTOCOL_VERSION, 3);