diff --git a/lam/help/help.inc b/lam/help/help.inc index a9905bb1..83c48b49 100644 --- a/lam/help/help.inc +++ b/lam/help/help.inc @@ -100,6 +100,8 @@ $helpArray = array ( "

". _("LAM will not work if version is wrong!"). ""), + "214" => array ("ext" => "FALSE", "Headline" => _("Configuration Wizard") . " - " . _("Cache timeout"), + "Text" => _("This is the time in minutes which LAM caches its LDAP searches. Shorter times will stress LDAP more but decrease the possibility that changes are not identified.")), // 300 - 399 // Roland Gruber // profile editor diff --git a/lam/lib/config.inc b/lam/lib/config.inc index 9f03e35b..7665f170 100644 --- a/lam/lib/config.inc +++ b/lam/lib/config.inc @@ -87,9 +87,6 @@ class Config { // suffix for domains (Samba 3) var $Suff_domains; - // suffix for user/group mappings (Samba 3) - //var $Suff_map; - // minimum/maximum numbers for UID, GID and UID of Samba Hosts var $MinUID; var $MaxUID; @@ -117,6 +114,9 @@ class Config { // if "yes" use the new LDAP schema for Samba 3.x var $samba3; + // LDAP cache timeout + var $cache_timeout; + // name of configuration file var $file; @@ -169,10 +169,6 @@ class Config { $this->Suff_domains = chop(substr($line, 14, strlen($line)-14)); continue; } -/* if (substr($line, 0, 11) == "mapsuffix: ") { - $this->Suff_map = chop(substr($line, 11, strlen($line)-11)); - continue; - }*/ if (substr($line, 0, 8) == "minUID: ") { $this->MinUID = chop(substr($line, 8, strlen($line)-8)); continue; @@ -229,6 +225,10 @@ class Config { $this->samba3 = chop(substr($line, 8, strlen($line)-8)); continue; } + if (substr($line, 0, 14) == "cacheTimeout: ") { + $this->cache_timeout = chop(substr($line, 14, strlen($line)-14)); + continue; + } } fclose($file); } @@ -237,214 +237,212 @@ class Config { } } - // saves preferences to config file - function save() { - $conffile = substr(__FILE__, 0, strlen(__FILE__) - 15) . "/config/" . $this->file . ".conf"; - if (is_file($conffile) == True) { - // booleans to check if value was already saved - $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 = $save_maxlstent = $save_deflang = - $save_scriptPath = $save_scriptServer = $save_samba3 = $save_suffdom = - $save_suffmap = False; - $file = fopen($conffile, "r"); - $file_array = array(); - // read config file - while (!feof($file)) { - array_push($file_array, fgets($file, 1024)); - } - fclose($file); - // generate new configuration file - 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, 11) == "serverURL: ") { - $file_array[$i] = "serverURL: " . $this->ServerURL . "\n"; - $save_serverURL = True; - continue; - } - if (substr($file_array[$i], 0, 8) == "passwd: ") { - $file_array[$i] = "passwd: " . $this->Passwd . "\n"; - $save_passwd = True; - continue; - } - if (substr($file_array[$i], 0, 8) == "admins: ") { - $file_array[$i] = "admins: " . $this->Adminstring . "\n"; - $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; - } - if (substr($file_array[$i], 0, 14) == "domainsuffix: ") { - $file_array[$i] = "domainsuffix: " . $this->Suff_domains . "\n"; - $save_suffdom = True; - continue; - } -/* if (substr($file_array[$i], 0, 11) == "mapsuffix: ") { - $file_array[$i] = "mapsuffix: " . $this->Suff_map . "\n"; - $save_suffmap = True; - continue; - }*/ - if (substr($file_array[$i], 0, 8) == "minUID: ") { - $file_array[$i] = "minUID: " . $this->MinUID . "\n"; - $save_minUID = True; - continue; - } - if (substr($file_array[$i], 0, 8) == "maxUID: ") { - $file_array[$i] = "maxUID: " . $this->MaxUID . "\n"; - $save_maxUID = True; - continue; - } - if (substr($file_array[$i], 0, 8) == "minGID: ") { - $file_array[$i] = "minGID: " . $this->MinGID . "\n"; - $save_minGID = True; - continue; - } - if (substr($file_array[$i], 0, 8) == "maxGID: ") { - $file_array[$i] = "maxGID: " . $this->MaxGID . "\n"; - $save_maxGID = True; - continue; - } - if (substr($file_array[$i], 0, 12) == "minMachine: ") { - $file_array[$i] = "minMachine: " . $this->MinMachine . "\n"; - $save_minMach = True; - continue; - } - if (substr($file_array[$i], 0, 12) == "maxMachine: ") { - $file_array[$i] = "maxMachine: " . $this->MaxMachine . "\n"; - $save_maxMach = 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; - } - if (substr($file_array[$i], 0, 16) == "maxlistentries: ") { - $file_array[$i] = "maxlistentries: " . $this->maxlistentries . "\n"; - $save_maxlstent = True; - continue; - } - if (substr($file_array[$i], 0, 17) == "defaultLanguage: ") { - $file_array[$i] = "defaultLanguage: " . $this->defaultLanguage . "\n"; - $save_deflang = True; - continue; - } - if (substr($file_array[$i], 0, 12) == "scriptPath: ") { - $file_array[$i] = "scriptPath: " . $this->scriptPath . "\n"; - $save_scriptPath = True; - continue; - } - if (substr($file_array[$i], 0, 14) == "scriptServer: ") { - $file_array[$i] = "scriptServer: " . $this->scriptServer . "\n"; - $save_scriptServer = True; - continue; - } - if (substr($file_array[$i], 0, 8) == "samba3: ") { - $file_array[$i] = "samba3: " . $this->samba3 . "\n"; - $save_samba3 = True; - continue; + // saves preferences to config file + function save() { + $conffile = substr(__FILE__, 0, strlen(__FILE__) - 15) . "/config/" . $this->file . ".conf"; + if (is_file($conffile) == True) { + // booleans to check if value was already saved + $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 = $save_maxlstent = $save_deflang = + $save_scriptPath = $save_scriptServer = $save_samba3 = $save_suffdom = $save_cachetime = False; + $file = fopen($conffile, "r"); + $file_array = array(); + // read config file + while (!feof($file)) { + array_push($file_array, fgets($file, 1024)); + } + fclose($file); + // generate new configuration file + 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, 11) == "serverURL: ") { + $file_array[$i] = "serverURL: " . $this->ServerURL . "\n"; + $save_serverURL = True; + continue; + } + if (substr($file_array[$i], 0, 8) == "passwd: ") { + $file_array[$i] = "passwd: " . $this->Passwd . "\n"; + $save_passwd = True; + continue; + } + if (substr($file_array[$i], 0, 8) == "admins: ") { + $file_array[$i] = "admins: " . $this->Adminstring . "\n"; + $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; + } + if (substr($file_array[$i], 0, 14) == "domainsuffix: ") { + $file_array[$i] = "domainsuffix: " . $this->Suff_domains . "\n"; + $save_suffdom = True; + continue; + } + if (substr($file_array[$i], 0, 8) == "minUID: ") { + $file_array[$i] = "minUID: " . $this->MinUID . "\n"; + $save_minUID = True; + continue; + } + if (substr($file_array[$i], 0, 8) == "maxUID: ") { + $file_array[$i] = "maxUID: " . $this->MaxUID . "\n"; + $save_maxUID = True; + continue; + } + if (substr($file_array[$i], 0, 8) == "minGID: ") { + $file_array[$i] = "minGID: " . $this->MinGID . "\n"; + $save_minGID = True; + continue; + } + if (substr($file_array[$i], 0, 8) == "maxGID: ") { + $file_array[$i] = "maxGID: " . $this->MaxGID . "\n"; + $save_maxGID = True; + continue; + } + if (substr($file_array[$i], 0, 12) == "minMachine: ") { + $file_array[$i] = "minMachine: " . $this->MinMachine . "\n"; + $save_minMach = True; + continue; + } + if (substr($file_array[$i], 0, 12) == "maxMachine: ") { + $file_array[$i] = "maxMachine: " . $this->MaxMachine . "\n"; + $save_maxMach = 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; + } + if (substr($file_array[$i], 0, 16) == "maxlistentries: ") { + $file_array[$i] = "maxlistentries: " . $this->maxlistentries . "\n"; + $save_maxlstent = True; + continue; + } + if (substr($file_array[$i], 0, 17) == "defaultLanguage: ") { + $file_array[$i] = "defaultLanguage: " . $this->defaultLanguage . "\n"; + $save_deflang = True; + continue; + } + if (substr($file_array[$i], 0, 12) == "scriptPath: ") { + $file_array[$i] = "scriptPath: " . $this->scriptPath . "\n"; + $save_scriptPath = True; + continue; + } + if (substr($file_array[$i], 0, 14) == "scriptServer: ") { + $file_array[$i] = "scriptServer: " . $this->scriptServer . "\n"; + $save_scriptServer = True; + continue; + } + if (substr($file_array[$i], 0, 8) == "samba3: ") { + $file_array[$i] = "samba3: " . $this->samba3 . "\n"; + $save_samba3 = True; + continue; + } + if (substr($file_array[$i], 0, 14) == "cacheTimeout: ") { + $file_array[$i] = "cacheTimeout: " . $this->cache_timeout . "\n"; + $save_cachetime = True; + continue; + } + } + // check if we have to add new entries (e.g. if user upgraded LAM and has an old config file) + 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 . "\n"); + if (!$save_passwd == True) array_push($file_array, "\n\n# password to change these preferences via webfrontend\n" . "passwd: " . $this->Passwd . "\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->Adminstring . "\n"); + if (!$save_suffusr == True) array_push($file_array, "\n\n# suffix of users\n" . + "# e.g. ou=People,dc=yourdomain,dc=org\n" . "usersuffix: " . $this->Suff_users . "\n"); + if (!$save_suffgrp == True) array_push($file_array, "\n\n# suffix of groups\n" . + "# e.g. ou=Groups,dc=yourdomain,dc=org\n" . "groupsuffix: " . $this->Suff_groups . "\n"); + if (!$save_suffhst == True) array_push($file_array, "\n\n# suffix of Samba hosts\n" . + "# e.g. ou=machines,dc=yourdomain,dc=org\n" . "hostsuffix: " . $this->Suff_hosts . "\n"); + if (!$save_suffdom == True) array_push($file_array, "\n\n# suffix of Samba 3 domains\n" . + "# e.g. ou=domains,dc=yourdomain,dc=org\n" . "domainsuffix: " . $this->Suff_domains . "\n"); + if (!$save_minUID == True) array_push($file_array, "\n\n# minimum UID number\n" . "minUID: " . $this->MinUID . "\n"); + if (!$save_maxUID == True) array_push($file_array, "\n\n# maximum UID number\n" . "maxUID: " . $this->MaxUID . "\n"); + if (!$save_minGID == True) array_push($file_array, "\n\n# minimum GID number\n" . "minGID: " . $this->MinGID . "\n"); + if (!$save_maxGID == True) array_push($file_array, "\n\n# maximum GID number\n" . "maxGID: " . $this->MaxGID . "\n"); + if (!$save_minMach == True) array_push($file_array, "\n\n# minimum UID number for Samba hosts\n" . "minMachine: " . $this->MinMachine . "\n"); + if (!$save_maxMach == True) array_push($file_array, "\n\n# maximum UID number for Samba hosts\n" . "maxMachine: " . $this->MaxMachine . "\n"); + 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 . "\n"); + 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 . "\n"); + 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 . "\n"); + if (!$save_maxlstent == True) array_push($file_array, "\n\n# maximum number of rows to show in user/group/host lists\n" . "maxlistentries: " . $this->maxlistentries . "\n"); + if (!$save_deflang == True) array_push($file_array, "\n\n# default language (a line from config/language)\n" . "defaultLanguage: " . $this->defaultLanguage . "\n"); + if (!$save_scriptPath == True) array_push($file_array, "\n\n# Path to external Script\n" . "scriptPath: " . $this->scriptPath . "\n"); + if (!$save_scriptServer == True) array_push($file_array, "\n\n# Server of external Script\n" . "scriptServer: " . $this->scriptServer . "\n"); + if (!$save_samba3 == True) array_push($file_array, "\n\n# Set to \"yes\" only if you use the new Samba 3.x schema.\n" . "samba3: " . $this->samba3 . "\n"); + if (!$save_cachetime == True) array_push($file_array, "\n\n# Number of minutes LAM caches LDAP searches.\n" . "cacheTimeout: " . $this->cache_timeout . "\n"); + $file = fopen($conffile, "w"); + if ($file) { + for ($i = 0; $i < sizeof($file_array); $i++) fputs($file, $file_array[$i]); + fclose($file); + } + else { + StatusMessage("ERROR", "", _("Cannot open config file!") . " (" . $conffile . ")"); + exit; + } } } - // check if we have to add new entries (e.g. if user upgraded LAM and has an old config file) - 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 . "\n"); - if (!$save_passwd == True) array_push($file_array, "\n\n# password to change these preferences via webfrontend\n" . "passwd: " . $this->Passwd . "\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->Adminstring . "\n"); - if (!$save_suffusr == True) array_push($file_array, "\n\n# suffix of users\n" . - "# e.g. ou=People,dc=yourdomain,dc=org\n" . "usersuffix: " . $this->Suff_users . "\n"); - if (!$save_suffgrp == True) array_push($file_array, "\n\n# suffix of groups\n" . - "# e.g. ou=Groups,dc=yourdomain,dc=org\n" . "groupsuffix: " . $this->Suff_groups . "\n"); - if (!$save_suffhst == True) array_push($file_array, "\n\n# suffix of Samba hosts\n" . - "# e.g. ou=machines,dc=yourdomain,dc=org\n" . "hostsuffix: " . $this->Suff_hosts . "\n"); - if (!$save_suffdom == True) array_push($file_array, "\n\n# suffix of Samba 3 domains\n" . - "# e.g. ou=domains,dc=yourdomain,dc=org\n" . "domainsuffix: " . $this->Suff_domains . "\n"); -// if (!$save_suffmap == True) array_push($file_array, "\n\n# suffix of Samba 3 user/group mappings\n" . -// "# e.g. ou=mappings,dc=yourdomain,dc=org\n" . "mapsuffix: " . $this->Suff_map . "\n"); - if (!$save_minUID == True) array_push($file_array, "\n\n# minimum UID number\n" . "minUID: " . $this->MinUID . "\n"); - if (!$save_maxUID == True) array_push($file_array, "\n\n# maximum UID number\n" . "maxUID: " . $this->MaxUID . "\n"); - if (!$save_minGID == True) array_push($file_array, "\n\n# minimum GID number\n" . "minGID: " . $this->MinGID . "\n"); - if (!$save_maxGID == True) array_push($file_array, "\n\n# maximum GID number\n" . "maxGID: " . $this->MaxGID . "\n"); - if (!$save_minMach == True) array_push($file_array, "\n\n# minimum UID number for Samba hosts\n" . "minMachine: " . $this->MinMachine . "\n"); - if (!$save_maxMach == True) array_push($file_array, "\n\n# maximum UID number for Samba hosts\n" . "maxMachine: " . $this->MaxMachine . "\n"); - 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 . "\n"); - 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 . "\n"); - 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 . "\n"); - if (!$save_maxlstent == True) array_push($file_array, "\n\n# maximum number of rows to show in user/group/host lists\n" . "maxlistentries: " . $this->maxlistentries . "\n"); - if (!$save_deflang == True) array_push($file_array, "\n\n# default language (a line from config/language)\n" . "defaultLanguage: " . $this->defaultLanguage . "\n"); - if (!$save_scriptPath == True) array_push($file_array, "\n\n# Path to external Script\n" . "scriptPath: " . $this->scriptPath . "\n"); - if (!$save_scriptServer == True) array_push($file_array, "\n\n# Server of external Script\n" . "scriptServer: " . $this->scriptServer . "\n"); - if (!$save_samba3 == True) array_push($file_array, "\n\n# Set to \"yes\" only if you use the new Samba 3.x schema.\n" . "samba3: " . $this->samba3 . "\n"); - $file = fopen($conffile, "w"); - if ($file) { - for ($i = 0; $i < sizeof($file_array); $i++) fputs($file, $file_array[$i]); - fclose($file); - } - else { - StatusMessage("ERROR", "", _("Cannot open config file!") . " (" . $conffile . ")"); - exit; - } - } -} - // prints current preferences - function printconf() { - echo "" . _("Server address") . ": " . $this->ServerURL . "
"; - echo "" . _("Samba 3.x schema") . ": " . $this->samba3 . "
"; - echo "" . _("UserSuffix") . ": " . $this->Suff_users . "
"; - echo "" . _("GroupSuffix") . ": " . $this->Suff_groups . "
"; - echo "" . _("HostSuffix") . ": " . $this->Suff_hosts . "
"; - echo "" . _("DomainSuffix") . ": " . $this->Suff_domains . "
"; -// echo "" . _("MappingSuffix") . ": " . $this->Suff_map . "
"; - echo "" . _("Minimum UID number") . ": " . $this->MinUID . "
"; - echo "" . _("Maximum UID number") . ": " . $this->MaxUID . "
"; - echo "" . _("Minimum GID number") . ": " . $this->MinGID . "
"; - echo "" . _("Maximum GID number") . ": " . $this->MaxGID . "
"; - echo "" . _("Minimum Machine number") . ": " . $this->MinMachine . "
"; - echo "" . _("Maximum Machine number") . ": " . $this->MaxMachine . "
"; - echo "" . _("Attributes in User List") . ": " . $this->userlistAttributes . "
"; - echo "" . _("Attributes in Group List") . ": " . $this->grouplistAttributes . "
"; - echo "" . _("Attributes in Host List") . ": " . $this->hostlistAttributes . "
"; - echo "" . _("Maximum list entries") . ": " . $this->maxlistentries . "
"; - echo "" . _("Default language") . ": " . $this->defaultLanguage . "
"; - echo "" . _("Path to external script") . ": " . $this->scriptPath . "
"; - echo "" . _("Server of external script") . ": " . $this->scriptServer . "
"; - echo "" . _("List of valid users") . ": " . $this->Adminstring; - } + // prints current preferences + function printconf() { + echo "" . _("Server address") . ": " . $this->ServerURL . "
"; + echo "" . _("Cache timeout") . ": " . $this->cache_timeout . "
"; + echo "" . _("Samba 3.x schema") . ": " . $this->samba3 . "
"; + echo "" . _("UserSuffix") . ": " . $this->Suff_users . "
"; + echo "" . _("GroupSuffix") . ": " . $this->Suff_groups . "
"; + echo "" . _("HostSuffix") . ": " . $this->Suff_hosts . "
"; + echo "" . _("DomainSuffix") . ": " . $this->Suff_domains . "
"; + echo "" . _("Minimum UID number") . ": " . $this->MinUID . "
"; + echo "" . _("Maximum UID number") . ": " . $this->MaxUID . "
"; + echo "" . _("Minimum GID number") . ": " . $this->MinGID . "
"; + echo "" . _("Maximum GID number") . ": " . $this->MaxGID . "
"; + echo "" . _("Minimum Machine number") . ": " . $this->MinMachine . "
"; + echo "" . _("Maximum Machine number") . ": " . $this->MaxMachine . "
"; + echo "" . _("Attributes in User List") . ": " . $this->userlistAttributes . "
"; + echo "" . _("Attributes in Group List") . ": " . $this->grouplistAttributes . "
"; + echo "" . _("Attributes in Host List") . ": " . $this->hostlistAttributes . "
"; + echo "" . _("Maximum list entries") . ": " . $this->maxlistentries . "
"; + echo "" . _("Default language") . ": " . $this->defaultLanguage . "
"; + echo "" . _("Path to external script") . ": " . $this->scriptPath . "
"; + echo "" . _("Server of external script") . ": " . $this->scriptServer . "
"; + echo "" . _("List of valid users") . ": " . $this->Adminstring; + } - // functions to read/write preferences + // functions to read/write preferences - // returns the server address as string - function get_ServerURL() { - return $this->ServerURL; - } + // returns the server address as string + function get_ServerURL() { + return $this->ServerURL; + } // sets the server address function set_ServerURL($value) { @@ -559,21 +557,6 @@ class Config { return true; } - // returns the LDAP suffix where mappings are saved -/* function get_MapSuffix() { - return $this->Suff_map; - }*/ - - // sets the LDAP suffix where mappings are saved -/* function set_MapSuffix($value) { - if (!$value) $this->Suff_map = ""; // optional parameter - elseif (is_string($value) && (eregi("^(([a-z]|-|[0-9])*=([a-z]|-|[0-9])*)(,([a-z]|-|[0-9])*=([a-z]|-|[0-9])*)*$", $value))) { - $this->Suff_map = $value; - } - else return false; - return true; - }*/ - // returns the minimum UID to use when creating new users function get_minUID() { return $this->MinUID; @@ -754,6 +737,19 @@ class Config { return true; } + // returns the LDAP cache timeout in minutes + function get_cacheTimeout() { + return $this->cache_timeout; + } + + // sets the LDAP cache timeout in minutes + function set_cacheTimeout($value) { + if (is_numeric($value) && ($value > -1)) { + $this->cache_timeout = $value; + } + else return false; + return true; + } } diff --git a/lam/templates/config/confmain.php b/lam/templates/config/confmain.php index 475454a2..9499a040 100644 --- a/lam/templates/config/confmain.php +++ b/lam/templates/config/confmain.php @@ -42,17 +42,17 @@ if ($_POST['back'] || $_POST['submitconf']){ if ($_POST['passwd1']) $_SESSION['passwd1'] = $_POST['passwd1']; if ($_POST['passwd2']) $_SESSION['passwd2'] = $_POST['passwd2']; if ($_POST['serverurl']) $_SESSION['serverurl'] = $_POST['serverurl']; + if (isset($_POST['cache_timeout'])) $_SESSION['cache_timeout'] = $_POST['cache_timeout']; if ($_POST['admins']) $_SESSION['admins'] = $_POST['admins']; if ($_POST['suffusers']) $_SESSION['suffusers'] = $_POST['suffusers']; if ($_POST['suffgroups']) $_SESSION['suffgroups'] = $_POST['suffgroups']; if ($_POST['suffhosts']) $_SESSION['suffhosts'] = $_POST['suffhosts']; if ($_POST['suffdomains']) $_SESSION['suffdomains'] = $_POST['suffdomains']; -// if ($_POST['suffmap']) $suffmap = $_POST['suffmap']; - if ($_POST['minUID']) $_SESSION['minUID'] = $_POST['minUID']; + if (isset($_POST['minUID'])) $_SESSION['minUID'] = $_POST['minUID']; if ($_POST['maxUID']) $_SESSION['maxUID'] = $_POST['maxUID']; - if ($_POST['minGID']) $_SESSION['minGID'] = $_POST['minGID']; + if (isset($_POST['minGID'])) $_SESSION['minGID'] = $_POST['minGID']; if ($_POST['maxGID']) $_SESSION['maxGID'] = $_POST['maxGID']; - if ($_POST['minMach']) $_SESSION['minMach'] = $_POST['minMach']; + if (isset($_POST['minMach'])) $_SESSION['minMach'] = $_POST['minMach']; if ($_POST['maxMach']) $_SESSION['maxMach'] = $_POST['maxMach']; if ($_POST['usrlstattr']) $_SESSION['usrlstattr'] = $_POST['usrlstattr']; if ($_POST['grplstattr']) $_SESSION['grplstattr'] = $_POST['grplstattr']; @@ -141,11 +141,18 @@ echo ("". _("DomainSuffix") . " **: ". "get_DomainSuffix() . "\">\n"); echo ("" . _("Help") . "\n"); -// mapping suffix -/*echo ("". - _("MappingSuffix") . ": ". - "get_MapSuffix() . "\">\n"); -echo ("" . _("Help") . "\n");*/ +// LDAP cache timeout +echo ("". + _("Cache timeout") . " *: ". + "\n"); +echo ("" . _("Help") . "\n"); echo (""); echo (""); diff --git a/lam/templates/config/confsave.php b/lam/templates/config/confsave.php index c64c20be..47887ddc 100644 --- a/lam/templates/config/confsave.php +++ b/lam/templates/config/confsave.php @@ -38,17 +38,18 @@ if ($_SESSION['passwd']) $passwd = $_SESSION['passwd']; if ($_SESSION['passwd1']) $passwd1 = $_SESSION['passwd1']; if ($_SESSION['passwd2']) $passwd2 = $_SESSION['passwd2']; if ($_SESSION['serverurl']) $serverurl = $_SESSION['serverurl']; +if (isset($_SESSION['serverurl'])) $serverurl = $_SESSION['serverurl']; if ($_SESSION['admins']) $admins = $_SESSION['admins']; if ($_SESSION['suffusers']) $suffusers = $_SESSION['suffusers']; if ($_SESSION['suffgroups']) $suffgroups = $_SESSION['suffgroups']; if ($_SESSION['suffhosts']) $suffhosts = $_SESSION['suffhosts']; if ($_SESSION['suffdomains']) $suffdomains = $_SESSION['suffdomains']; //if ($_SESSION['suffmap']) $suffmap = $_SESSION['suffmap']; -if ($_SESSION['minUID']) $minUID = $_SESSION['minUID']; +if (isset($_SESSION['minUID'])) $minUID = $_SESSION['minUID']; if ($_SESSION['maxUID']) $maxUID = $_SESSION['maxUID']; -if ($_SESSION['minGID']) $minGID = $_SESSION['minGID']; +if (isset($_SESSION['minGID'])) $minGID = $_SESSION['minGID']; if ($_SESSION['maxGID']) $maxGID = $_SESSION['maxGID']; -if ($_SESSION['minMach']) $minMach = $_SESSION['minMach']; +if (isset($_SESSION['minMach'])) $minMach = $_SESSION['minMach']; if ($_SESSION['maxMach']) $maxMach = $_SESSION['maxMach']; if ($_SESSION['usrlstattr']) $usrlstattr = $_SESSION['usrlstattr']; if ($_SESSION['grplstattr']) $grplstattr = $_SESSION['grplstattr']; @@ -82,6 +83,11 @@ if (!$serverurl) { echo ("\n


" . _("Back to preferences...") . ""); exit; } +if (!isset($cache_timeout) || !(is_numeric($cache_timeout)) || !($cache_timeout > -1)) { + echo ("" . _("Cache timeout is empty!") . ""); + echo ("\n


" . _("Back to preferences...") . ""); + exit; +} if (!$admins || !eregi("^([a-z0-9]|-)+=([a-z0-9]|-)+(,([a-z0-9]|-)+=([a-z0-9]|-)+)+(;([a-z0-9]|-)+=([a-z0-9]|-)+(,([a-z0-9]|-)+=([a-z0-9]|-)+)+)*$", $admins)) { echo ("" . _("List of admin users is empty or invalid!") . ""); echo ("\n


" . _("Back to preferences...") . ""); @@ -107,12 +113,7 @@ if (($samba3 == "yes") && !eregi("^(([a-z]|-|[0-9])*=([a-z]|-|[0-9])*)(,([a-z]|- echo ("\n


" . _("Back to preferences...") . ""); exit; } -/*if ($suffmap && !eregi("^(([a-z]|-|[0-9])*=([a-z]|-|[0-9])*)(,([a-z]|-|[0-9])*=([a-z]|-|[0-9])*)*$", $suffmap)) { - echo ("" . _("MappingSuffix is invalid!") . ""); - echo ("\n


" . _("Back to preferences...") . ""); - exit; -}*/ -if (!$minUID || !is_numeric($minUID)) { +if (!isset($minUID) || !is_numeric($minUID)) { echo ("" . _("MinUID is invalid!") . ""); echo ("\n


" . _("Back to preferences...") . ""); exit; @@ -122,7 +123,7 @@ if (!$maxUID || !is_numeric($maxUID)) { echo ("\n


" . _("Back to preferences...") . ""); exit; } -if (!$minGID || !is_numeric($minGID)) { +if (!isset($minGID) || !is_numeric($minGID)) { echo ("" . _("MinGID is invalid!") . ""); echo ("\n


" . _("Back to preferences...") . ""); exit; @@ -132,7 +133,7 @@ if (!$maxGID || !is_numeric($maxGID)) { echo ("\n


" . _("Back to preferences...") . ""); exit; } -if (!$minMach || !is_numeric($minMach)) { +if (!isset($minMach) || !is_numeric($minMach)) { echo ("" . _("MinMachine is invalid!") . ""); echo ("\n


" . _("Back to preferences...") . ""); exit; @@ -189,12 +190,12 @@ if ($scriptserver && !is_string($scriptserver)) { // set new preferences $conf->set_ServerURL($serverurl); +$conf->set_cacheTimeout($cache_timeout); $conf->set_Adminstring($admins); $conf->set_UserSuffix($suffusers); $conf->set_GroupSuffix($suffgroups); $conf->set_HostSuffix($suffhosts); $conf->set_DomainSuffix($suffdomains); -//$conf->set_MapSuffix($suffmap); $conf->set_minUID($minUID); $conf->set_maxUID($maxUID); $conf->set_minGID($minGID); @@ -235,12 +236,12 @@ unset($_SESSION['passwd']); unset($_SESSION['passwd1']); unset($_SESSION['passwd2']); unset($_SESSION['serverurl']); +unset($_SESSION['cache_timeout']); unset($_SESSION['admins']); unset($_SESSION['suffusers']); unset($_SESSION['suffgroups']); unset($_SESSION['suffhosts']); unset($_SESSION['suffdomains']); -//unset($_SESSION['suffmap']); unset($_SESSION['minUID']); unset($_SESSION['maxUID']); unset($_SESSION['minGID']); diff --git a/lam/tests/conf-test.php b/lam/tests/conf-test.php index ca52884b..c94b278f 100644 --- a/lam/tests/conf-test.php +++ b/lam/tests/conf-test.php @@ -9,12 +9,12 @@ $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 GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA @@ -24,7 +24,7 @@ $Id$ */ include ("../lib/config.inc"); -$conf = new Config(); +$conf = new Config('test'); echo ""; echo (" Current Config

"); $conf->printconf(); @@ -32,6 +32,7 @@ echo ("

Starting Test...

"); // now all prferences are loaded echo ("Loading preferences..."); $ServerURL = $conf->get_ServerURL(); +$cache_timeout = $conf->get_cacheTimeout(); $Admins = $conf->get_Admins(); $Passwd = $conf->get_Passwd(); $Adminstring = $conf->get_Adminstring(); @@ -39,7 +40,6 @@ $Suff_users = $conf->get_UserSuffix(); $Suff_groups = $conf->get_GroupSuffix(); $Suff_hosts = $conf->get_HostSuffix(); $Suff_domains = $conf->get_DomainSuffix(); -$Suff_map = $conf->get_MapSuffix(); $MinUID = $conf->get_minUID(); $MaxUID = $conf->get_maxUID(); $MinGID = $conf->get_minGID(); @@ -58,6 +58,7 @@ echo ("done
"); // next we modify them and save lam.conf echo ("Changing preferences..."); $conf->set_ServerURL("ldap://123.345.678.123:777"); +$conf->set_cacheTimeout("33"); $conf->set_Admins(array("uid=test,o=test,dc=org","uid=root,o=test2,c=de")); $conf->set_Passwd("123456abcde"); $conf->set_Adminstring("uid=test,o=test,dc=org;uid=root,o=test2,c=de"); @@ -65,7 +66,6 @@ $conf->set_UserSuffix("ou=test,o=test,c=de"); $conf->set_GroupSuffix("ou=testgrp,o=test,c=de"); $conf->set_HostSuffix("ou=testhst,o=test,c=de"); $conf->set_DomainSuffix("ou=testdom,o=test,c=de"); -$conf->set_MapSuffix("ou=testmap,o=test,c=de"); $conf->set_minUID("25"); $conf->set_maxUID("254"); $conf->set_minGID("253"); @@ -84,63 +84,63 @@ $conf->save(); echo ("done
"); // at last all preferences are read from lam.conf and compared echo ("Loading and comparing..."); -$conf = new Config('default'); -if ($conf->get_ServerURL() != "ldap://123.345.678.123:777") echo ("
Saving ServerURL failed!
"); -$adm_arr = $conf->get_Admins(); +$conf2 = new Config('test'); +if ($conf2->get_ServerURL() != "ldap://123.345.678.123:777") echo ("
Saving ServerURL failed!
"); +if ($conf2->get_cacheTimeout() != "33") echo ("
Saving Cache timeout failed!
"); +$adm_arr = $conf2->get_Admins(); if ($adm_arr[0] != "uid=test,o=test,dc=org") echo ("
Saving admins failed!" . $adm_arr[0] . "
"); if ($adm_arr[1] != "uid=root,o=test2,c=de") echo ("
Saving admins failed!
"); -if ($conf->get_Passwd() != "123456abcde") echo ("
Saving password failed!
"); -if ($conf->get_Adminstring() != "uid=test,o=test,dc=org;uid=root,o=test2,c=de") echo ("
Saving admin string failed!
"); -if ($conf->get_UserSuffix() != "ou=test,o=test,c=de") echo ("
Saving user suffix failed!
"); -if ($conf->get_GroupSuffix() != "ou=testgrp,o=test,c=de") echo ("
Saving group suffix failed!
"); -if ($conf->get_HostSuffix() != "ou=testhst,o=test,c=de") echo ("
Saving host suffix failed!
"); -if ($conf->get_DomainSuffix() != "ou=testdom,o=test,c=de") echo ("
Saving domain suffix failed!
"); -if ($conf->get_MapSuffix() != "ou=testmap,o=test,c=de") echo ("
Saving mapping suffix failed!
"); -if ($conf->get_minUID() != "25") echo ("
Saving minUID failed!
"); -if ($conf->get_maxUID() != "254") echo ("
Saving maxUID failed!
"); -if ($conf->get_minGID() != "253") echo ("
Saving minGID failed!
"); -if ($conf->get_maxGID() != "1234") echo ("
Saving maxGID failed!
"); -if ($conf->get_minMachine() != "3") echo ("
Saving maxMachine failed!
"); -if ($conf->get_maxMachine() != "47") echo ("
Saving minMachine 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!
"); -if ($conf->get_maxlistentries() != "54") echo ("
Saving maxlistentries failed!
"); -if ($conf->get_defaultlanguage() != "de_AT:iso639_de:Deutsch (Oesterreich)") echo ("
Saving default language failed!
"); -if ($conf->get_scriptPath() != "/var/www/lam/lib/script") echo ("
Saving script path failed!
"); -if ($conf->get_scriptServer() != "127.0.0.1") echo ("
Saving script server failed!
"); -if ($conf->get_samba3() != "yes") echo ("
Saving samba3 failed!
"); +if ($conf2->get_Passwd() != "123456abcde") echo ("
Saving password failed!
"); +if ($conf2->get_Adminstring() != "uid=test,o=test,dc=org;uid=root,o=test2,c=de") echo ("
Saving admin string failed!
"); +if ($conf2->get_UserSuffix() != "ou=test,o=test,c=de") echo ("
Saving user suffix failed!
"); +if ($conf2->get_GroupSuffix() != "ou=testgrp,o=test,c=de") echo ("
Saving group suffix failed!
"); +if ($conf2->get_HostSuffix() != "ou=testhst,o=test,c=de") echo ("
Saving host suffix failed!
"); +if ($conf2->get_DomainSuffix() != "ou=testdom,o=test,c=de") echo ("
Saving domain suffix failed!
"); +if ($conf2->get_minUID() != "25") echo ("
Saving minUID failed!
"); +if ($conf2->get_maxUID() != "254") echo ("
Saving maxUID failed!
"); +if ($conf2->get_minGID() != "253") echo ("
Saving minGID failed!
"); +if ($conf2->get_maxGID() != "1234") echo ("
Saving maxGID failed!
"); +if ($conf2->get_minMachine() != "3") echo ("
Saving maxMachine failed!
"); +if ($conf2->get_maxMachine() != "47") echo ("
Saving minMachine failed!
"); +if ($conf2->get_userlistAttributes() != "#uid;#cn") echo ("
Saving userlistAttributes failed!
"); +if ($conf2->get_grouplistAttributes() != "#gidNumber;#cn;#memberUID") echo ("
Saving grouplistAttributes failed!
"); +if ($conf2->get_hostlistAttributes() != "#cn;#uid;#description") echo ("
Saving hostlistAttributes failed!
"); +if ($conf2->get_maxlistentries() != "54") echo ("
Saving maxlistentries failed!
"); +if ($conf2->get_defaultlanguage() != "de_AT:iso639_de:Deutsch (Oesterreich)") echo ("
Saving default language failed!
"); +if ($conf2->get_scriptPath() != "/var/www/lam/lib/script") echo ("
Saving script path failed!
"); +if ($conf2->get_scriptServer() != "127.0.0.1") echo ("
Saving script server failed!
"); +if ($conf2->get_samba3() != "yes") echo ("
Saving samba3 failed!
"); echo ("done
"); // restore old values echo ("Restoring old preferences..."); -$conf->set_ServerURL($ServerURL); -$conf->set_Admins($Admins); -$conf->set_Passwd($Passwd); -$conf->set_Adminstring($Adminstring); -$conf->set_UserSuffix($Suff_users); -$conf->set_GroupSuffix($Suff_groups); -$conf->set_HostSuffix($Suff_hosts); -$conf->set_DomainSuffix($Suff_domains); -$conf->set_MapSuffix($Suff_map); -$conf->set_minUID($MinUID); -$conf->set_maxUID($MaxUID); -$conf->set_minGID($MinGID); -$conf->set_maxGID($MaxGID); -$conf->set_minMachine($MinMachine); -$conf->set_maxMachine($MaxMachine); -$conf->set_userlistAttributes($userlistAttributes); -$conf->set_grouplistAttributes($grouplistAttributes); -$conf->set_hostlistAttributes($hostlistAttributes); -$conf->set_maxlistentries($maxlistentries); -$conf->set_defaultLanguage($defaultlanguage); -$conf->set_scriptPath($scriptpath); -$conf->set_scriptServer($scriptserver); -$conf->set_samba3($samba3); -$conf->save(); +$conf2->set_ServerURL($ServerURL); +$conf2->set_cacheTimeout($cache_timeout); +$conf2->set_Admins($Admins); +$conf2->set_Passwd($Passwd); +$conf2->set_Adminstring($Adminstring); +$conf2->set_UserSuffix($Suff_users); +$conf2->set_GroupSuffix($Suff_groups); +$conf2->set_HostSuffix($Suff_hosts); +$conf2->set_DomainSuffix($Suff_domains); +$conf2->set_minUID($MinUID); +$conf2->set_maxUID($MaxUID); +$conf2->set_minGID($MinGID); +$conf2->set_maxGID($MaxGID); +$conf2->set_minMachine($MinMachine); +$conf2->set_maxMachine($MaxMachine); +$conf2->set_userlistAttributes($userlistAttributes); +$conf2->set_grouplistAttributes($grouplistAttributes); +$conf2->set_hostlistAttributes($hostlistAttributes); +$conf2->set_maxlistentries($maxlistentries); +$conf2->set_defaultLanguage($defaultlanguage); +$conf2->set_scriptPath($scriptpath); +$conf2->set_scriptServer($scriptserver); +$conf2->set_samba3($samba3); +$conf2->save(); echo ("done
"); // finished echo ("
Test is complete."); echo ("

Current Config

"); -$conf->printconf(); +$conf2->printconf(); ?>