From cc756735cb47cf1f65f459e5cdac75ff52529c6c Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sun, 30 Mar 2003 19:51:47 +0000 Subject: [PATCH] added attribute options for user/group/host lists --- lam/config/config.php | 87 +++++++++++++++++++++++++++++++++++--- lam/config/confmain.php | 93 +++++++++++++++++++++++------------------ lam/config/confsave.php | 20 ++++++++- lam/lam.conf | 18 ++++++++ lam/tests/conf-test.php | 12 ++++++ 5 files changed, 183 insertions(+), 47 deletions(-) diff --git a/lam/config/config.php b/lam/config/config.php index 94ed3743..76fa9800 100644 --- a/lam/config/config.php +++ b/lam/config/config.php @@ -9,7 +9,7 @@ $Id$ it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -63,7 +63,12 @@ class Config { var $MaxGID; var $MinMachine; var $MaxMachine; - + + // attributes that are shown in the user/group/host tables + var $userlistAttributes; + var $grouplistAttributes; + var $hostlistAttributes; + // default shell and list of possible shells var $DefaultShell; var $ShellList; @@ -148,6 +153,18 @@ class Config { $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; + } + if (substr($line, 0, 21) == "grouplistAttributes: ") { + $this->grouplistAttributes = chop(substr($line, 21, strlen($line)-21)); + continue; + } + if (substr($line, 0, 20) == "hostlistAttributes: ") { + $this->hostlistAttributes = chop(substr($line, 20, strlen($line)-20)); + continue; + } } fclose($file); } @@ -162,7 +179,8 @@ class Config { 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 = False; + $save_minUID = $save_maxUID = $save_minGID = $save_maxGID = $save_minMach = $save_maxMach = $save_defShell = + $save_shellList = $save_usrlstatrr = $save_grplstatrr = $save_hstlstatrr = False; $file = fopen($conffile, "r"); $file_array = array(); while (!feof($file)) { @@ -252,6 +270,21 @@ class Config { $save_shellList = True; continue; } + if (substr($file_array[$i], 0, 20) == "userlistAttributes: ") { + $file_array[$i] = "userlistAttributes: " . $this->userlistAttributes . "\n"; + $save_usrlstattr = True; + continue; + } + if (substr($file_array[$i], 0, 21) == "grouplistAttributes: ") { + $file_array[$i] = "grouplistAttributes: " . $this->grouplistAttributes . "\n"; + $save_grplstattr = True; + continue; + } + if (substr($file_array[$i], 0, 20) == "hostlistAttributes: ") { + $file_array[$i] = "hostlistAttributes: " . $this->hostlistAttributes . "\n"; + $save_hstlstattr = True; + continue; + } } // 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); @@ -274,7 +307,13 @@ class Config { 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" . "shellList: " . $this->ShellList); + 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')" . + "\n# or individual ones (e.g. 'cn:Group Name')\n# values have to be seperated by semicolons\n" . "grouplistAttributes: " . $this->grouplistAttributes); + if (!$save_hstlstattr == True) array_push($file_array, "\n\n# list of attributes to show in host list\n# entries can either be predefined values (e.g. '#cn' or '#uid')" . + "\n# or individual ones (e.g. 'cn:Host Name')\n# values have to be seperated by semicolons\n" . "hostlistAttributes: " . $this->hostlistAttributes); $file = fopen($conffile, "w"); if ($file) { for ($i = 0; $i < sizeof($file_array); $i++) fputs($file, $file_array[$i]); @@ -286,7 +325,7 @@ class Config { } } } - + // prints current preferences function printconf() { echo _("SSL: " ) . $this->SSL . "
"; @@ -302,6 +341,9 @@ class Config { echo _("maxGID: ") . $this->MaxGID . "
"; echo _("minMachine: ") . $this->MinMachine . "
"; 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; } @@ -500,13 +542,46 @@ class Config { 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; + } + + // sets the list of attributes to show in user list + function set_userlistAttributes($value) { + if (is_string($value)) $this->userlistAttributes = $value; + else echo _("Config->set_userlistAttributes failed!"); + } + + // returns the list of attributes to show in group list + function get_grouplistAttributes() { + return $this->grouplistAttributes; + } + + // sets the list of attributes to show in group list + function set_grouplistAttributes($value) { + if (is_string($value)) $this->grouplistAttributes = $value; + else echo _("Config->set_grouplistAttributes failed!"); + } + + // returns the list of attributes to show in host list + function get_hostlistAttributes() { + return $this->hostlistAttributes; + } + + // sets the list of attributes to show in host list + function set_hostlistAttributes($value) { + if (is_string($value)) $this->hostlistAttributes = $value; + else echo _("Config->set_hostlistAttributes failed!"); + } + } ?> diff --git a/lam/config/confmain.php b/lam/config/confmain.php index e6a98963..ab2ddff1 100644 --- a/lam/config/confmain.php +++ b/lam/config/confmain.php @@ -49,48 +49,61 @@ echo ("\n"); echo ("" . _("LDAP Account Manager Configuration") . "\n"); echo ("\n"); echo ("\n"); -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"); -echo ("\n"); -echo ("\n"); -echo ("\n"); -echo ("\n"); -echo (""); -echo ("\n"); -echo ("\n"); -echo ("\n"); -echo ("\n"); -echo ("\n"); -echo ("\n"); -echo (""); -echo ("\n"); -echo ("\n"); -echo ("\n"); -echo ("\n"); -echo (""); -echo ("\n"); -echo ("\n"); -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.") . "

" . _("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)") . "

 

" . _("UserSuffix") . ":

get_UserSuffix() . "\">

" . _("This is the suffix from where to search for users.
(e.g. ou=People,dc=yourcompany,dc=com)=") . "

" . _("GroupSuffix") . ":

get_GroupSuffix() . "\">

" . _("This is the suffix from where to search for groups.
(e.g. ou=group,dc=yourcompany,dc=com)") . "

" . _("HostSuffix") . ":

get_HostSuffix() . "\">

" . _("This is the suffix from where to search for Samba hosts.
(e.g. ou=machines,dc=yourcompany,dc=com)") . "

 

" . _("Minimum UID number") . ":

get_minUID() . "\">\n"); -echo ("  " . _("Maximum UID number") . ": get_maxUID() . "\">

" . _("These are the minimum and maximum numbers to use for user IDs") . "

" . _("Minimum GID number") . ":

get_minGID() . "\">\n"); -echo ("  " . _("Maximum GID number") . ": get_maxGID() . "\">

" . _("These are the minimum and maximum numbers to use for group IDs") . "

" . _("Minimum Machine number") . ":

get_minMachine() . "\">\n"); -echo ("  " . _("Maximum Machine number") . ": get_maxMachine() . "\">

" . _("These are the minimum and maximum numbers to use for Samba hosts.
Do not use the same range as for user IDs.") . "

 

" . _("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.") . "

 

" . _("New Password") . ":

" . _("Reenter Password") . ":

 
 

"); +echo ("\n"); +echo ("\n"); +echo ("\n"); +echo _("\n"); +if ($conf->get_SSL() == "True") echo ("\n"); +else echo ("\n"); +echo ("\n"); +echo (""); +echo ("\n"); +echo ("\n"); +echo (""); +echo ("\n"); +echo ("\n"); +echo ("\n"); +echo ("\n"); +echo ("\n"); +echo ("\n"); +echo (""); +echo ("\n"); +echo ("\n"); +echo ("\n"); +echo ("\n"); +echo ("\n"); +echo ("\n"); +echo (""); +echo (""); +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.") . "

 

" . _("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)") . "

 

" . _("UserSuffix") . ":

get_UserSuffix() . "\">

" . _("This is the suffix from where to search for users.
(e.g. ou=People,dc=yourcompany,dc=com)") . "

" . _("GroupSuffix") . ":

get_GroupSuffix() . "\">

" . _("This is the suffix from where to search for groups.
(e.g. ou=group,dc=yourcompany,dc=com)") . "

" . _("HostSuffix") . ":

get_HostSuffix() . "\">

" . _("This is the suffix from where to search for Samba hosts.
(e.g. ou=machines,dc=yourcompany,dc=com)") . "

 
" . _("Minimum UID number") . ": get_minUID() . "\">\n"); +echo ("  " . _("Maximum UID number") . ": get_maxUID() . "\">

" . _("These are the minimum and maximum numbers to use for user IDs") . "

" . _("Minimum GID number") . ": get_minGID() . "\">\n"); +echo ("  " . _("Maximum GID number") . ": get_maxGID() . "\">

" . _("These are the minimum and maximum numbers to use for group IDs") . "

" . _("Minimum Machine number") . ": get_minMachine() . "\">\n"); +echo ("  " . _("Maximum Machine number") . ": get_maxMachine() . "\">

" . _("These are the minimum and maximum numbers to use for Samba hosts.
Do not use the same range as for user IDs.") . "

 

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

get_userlistAttributes() . "\">

" . _("This is the list of attributes to show in the lists. The entries can either be predefined values (e.g. '#cn' or '#gidNumber') or individual ones (e.g. 'cn:Group Name'). The entries are seperated by semicolons.") + . "

" . _("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 (""); +echo (""); +echo ("\n"); +echo ("\n"); +echo ("
" . _("New Password") . ": " . _("Optional") . "
" . _("Reenter Password") . ":
\n"); +echo ("

 

\n"); +echo ("

 

\n"); +echo (""); +echo ("\n"); +echo ("
     ");
+echo ("
\n"); +echo ("
\n"); echo ("
\n"); echo ("\n"); echo ("\n"); diff --git a/lam/config/confsave.php b/lam/config/confsave.php index bee9f113..291c1e0d 100644 --- a/lam/config/confsave.php +++ b/lam/config/confsave.php @@ -106,6 +106,21 @@ if (chop($shellList) == "") { echo ("\n


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


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


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


" . _("Back to preferences...") . ""); + exit; +} // set new preferences $conf->set_Host($host); @@ -124,6 +139,9 @@ $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); // check if password was changed if ($pass1 != $pass2) { @@ -137,7 +155,7 @@ if ($pass1 != "") { } // save settings and display new settings $conf->save(); -echo ("" . _("Saving the following settings:") . "

"); +echo ("" . _("The following settings were saved:") . "

"); $conf->printconf(); echo ("




" . _("Back to Login") . ""); diff --git a/lam/lam.conf b/lam/lam.conf index 3c5400bf..e018c44c 100644 --- a/lam/lam.conf +++ b/lam/lam.conf @@ -46,3 +46,21 @@ shellList: /bin/bash;/bin/sh;/bin/false # default shell when creating new user defaultShell: /bin/bash + +# list of attributes to show in user list +# entries can either be predefined values (e.g. '#cn' or '#uid') +# or individual ones (e.g. 'uid:User ID' or 'host:Host Name') +# values have to be seperated by semicolons +userlistAttributes: #uid;#cn;#uidNumber;#gidNumber + +# list of attributes to show in group list +# entries can either be predefined values (e.g. '#cn' or '#gidNumber') +# or individual ones (e.g. 'cn:Group Name') +# values have to be seperated by semicolons +grouplistAttributes: #cn;#gidNumber + +# list of attributes to show in host list +# entries can either be predefined values (e.g. '#cn' or '#uid') +# or individual ones (e.g. 'cn:Host Name') +# values have to be seperated by semicolons +hostlistAttributes: #uid;#uidNumber;#description diff --git a/lam/tests/conf-test.php b/lam/tests/conf-test.php index 6481c71f..d3f51a62 100644 --- a/lam/tests/conf-test.php +++ b/lam/tests/conf-test.php @@ -47,6 +47,9 @@ $MinMachine = $conf->get_minMachine(); $MaxMachine = $conf->get_maxMachine(); $DefaultShell = $conf->get_defaultShell(); $ShellList = $conf->get_shellList(); +$userlistAttributes = $conf->get_userlistAttributes(); +$grouplistAttributes = $conf->get_grouplistAttributes(); +$hostlistAttributes = $conf->get_hostlistAttributes(); echo ("done
"); // next we modify them and save lam.conf echo ("Changing preferences..."); @@ -68,6 +71,9 @@ $conf->set_minMachine("3"); $conf->set_maxMachine("47"); $conf->set_defaultShell("/usr/bin/test"); $conf->set_shellList("/usr/bin/test;/usr/bin/false"); +$conf->set_userlistAttributes("#uid;#cn"); +$conf->set_grouplistAttributes("#gidNumber;#cn;#memberUID"); +$conf->set_hostlistAttributes("#cn;#uid;#description"); $conf->save(); echo ("done
"); // at last all preferences are read from lam.conf and compared @@ -92,6 +98,9 @@ if ($conf->get_minMachine() != "3") echo ("
Saving ma if ($conf->get_maxMachine() != "47") echo ("
Saving minMachine failed!
"); if ($conf->get_defaultShell() != "/usr/bin/test") echo ("
Saving default shell failed!
"); if ($conf->get_shellList() != "/usr/bin/test;/usr/bin/false") echo ("
Saving shellList failed!
"); +if ($conf->get_userlistAttributes() != "#uid;#cn") echo ("
Saving userlistAttributes failed!
"); +if ($conf->get_grouplistAttributes() != "#gidNumber;#cn;#memberUID") echo ("
Saving grouplistAttributes failed!
"); +if ($conf->get_hostlistAttributes() != "#cn;#uid;#description") echo ("
Saving hostlistAttributes failed!
"); echo ("done
"); // restore old values echo ("Restoring old preferences..."); @@ -112,6 +121,9 @@ $conf->set_minMachine($MinMachine); $conf->set_maxMachine($MaxMachine); $conf->set_defaultShell($DefaultShell); $conf->set_shellList($ShellList); +$conf->set_userlistAttributes($userlistAttributes); +$conf->set_grouplistAttributes($grouplistAttributes); +$conf->set_hostlistAttributes($hostlistAttributes); $conf->save(); echo ("done
"); // finished