diff --git a/lam/config/config.php b/lam/config/config.php index 76fa9800..f0c09cd4 100644 --- a/lam/config/config.php +++ b/lam/config/config.php @@ -28,16 +28,9 @@ $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,11 +240,9 @@ 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" . + 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" . "# 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\n# suffix of users\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 _("SSL: " ) . $this->SSL . "
"; - echo _("Host: ") . $this->Host . "
"; - echo _("Port: ") . $this->Port . "
"; + echo _("ServerURL: ") . $this->ServerURL . "
"; echo _("Admins: ") . $this->Adminstring . "
"; echo _("UserSuffix: ") . $this->Suff_users . "
"; echo _("GroupSuffix: ") . $this->Suff_groups . "
"; @@ -343,44 +290,20 @@ class Config { echo _("maxMachine: ") . $this->MaxMachine . "
"; echo _("userlistAttributes: ") . $this->userlistAttributes . "
"; echo _("grouplistAttributes: ") . $this->grouplistAttributes . "
"; - echo _("hostlistAttributes: ") . $this->hostlistAttributes . "
"; - echo _("Default Shell: ") . $this->DefaultShell . "
"; - echo _("Shell list: ") . $this->ShellList; + echo _("hostlistAttributes: ") . $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; diff --git a/lam/config/confmain.php b/lam/config/confmain.php index e6449d19..aeb409fd 100644 --- a/lam/config/confmain.php +++ b/lam/config/confmain.php @@ -52,13 +52,8 @@ echo ("\n"); echo ("

\"LDAP




\n"); echo ("
\n"); echo (""); -echo ("\n"); -echo ("\n"); -echo ("\n"); -echo _("\n"); -if ($conf->get_SSL() == "True") echo ("\n"); -else echo ("\n"); -echo ("\n"); +echo ("\n"); +echo ("\n"); echo (""); echo ("\n"); echo ("\n"); @@ -85,11 +80,6 @@ echo (""); echo (""); echo (""); -echo (""); -echo ("\n"); -echo ("\n"); -echo ("\n"); -echo ("\n"); echo ("

" . _("Hostname") . ":

get_Host() . "\">

" . _("Hostname of LDAP server") . "

" . _("Portnumber") . ":

get_Port() . "\">

Default is 389, use 636 for SSL connections

" . _("Use SSL") . ":

" . _("Use SSL") . ":

" . _("Check if your server supports secure connections.") . "

" . _("Server Address") . ":

get_ServerURL() . "\">

" . _("Server Address of LDAP server (e.g. ldap://localhost:389 or ldaps://localhost:636)") . "

 

" . _("List of valid users") . ":

get_Adminstring() . "\">

" . _("Usernames must be seperated by semicolons
(e.g. cn=admin,dc=yourcompany,dc=com;uid=root,ou=people,dc=yourcompany,dc=com)") . "

" . _("This is the list of attributes to show in the lis . "

" . _("Attributes in Group List:") . "

get_grouplistAttributes() . "\">

" . _("Attributes in Host List:") . "

get_hostlistAttributes() . "\">
 

" . _("Default shell") . ":

get_defaultShell() . "\">

" . _("Default shell when creating new users.") . "

" . _("Shell list") . ":

get_shellList() . "\">

" . _("List of possible shells when creating new users.
The entries have to be separated by semicolons.") . "

\n"); echo ("

 

\n"); echo (""); diff --git a/lam/config/confsave.php b/lam/config/confsave.php index 291c1e0d..3b24bada 100644 --- a/lam/config/confsave.php +++ b/lam/config/confsave.php @@ -41,13 +41,8 @@ if ($passwd != $conf->get_Passwd()) { echo ("




"); // check new preferences -if (chop($host) == "") { - echo _("" . _("Hostname is empty!") . ""); - echo ("\n


" . _("Back to preferences...") . ""); - exit; -} -if (chop($port) == "") { - echo _("" . _("Portnumber is empty!") . ""); +if (chop($serverurl) == "") { + echo _("" . _("Server Address is empty!") . ""); echo ("\n


" . _("Back to preferences...") . ""); exit; } @@ -96,16 +91,6 @@ if (chop($maxMach) == "") { echo ("\n


" . _("Back to preferences...") . ""); exit; } -if (chop($defShell) == "") { - echo _("" . _("Default shell is empty!") . ""); - echo ("\n


" . _("Back to preferences...") . ""); - exit; -} -if (chop($shellList) == "") { - echo _("" . _("Shell list is empty!") . ""); - echo ("\n


" . _("Back to preferences...") . ""); - exit; -} if (chop($usrlstattr) == "") { echo _("" . _("No attributes in user list!") . ""); echo ("\n


" . _("Back to preferences...") . ""); @@ -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); diff --git a/lam/lam.conf b/lam/lam.conf index 66de67ae..36582553 100644 --- a/lam/lam.conf +++ b/lam/lam.conf @@ -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 diff --git a/lam/lib/ldap.php b/lam/lib/ldap.php index 63d3762f..3fda9385 100644 --- a/lam/lib/ldap.php +++ b/lam/lib/ldap.php @@ -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);