From ce7665a2babfe45c8163f63e841ffbd2c98ed734 Mon Sep 17 00:00:00 2001 From: katagia Date: Sat, 7 Jun 2003 14:25:30 +0000 Subject: [PATCH] Started using help and write comments into file --- lam/help/help.inc | 127 +++++++++++- lam/lib/account.inc | 62 ++---- lam/templates/account.php | 400 ++++++++++++++++++++++---------------- lam/templates/delete.php | 13 +- 4 files changed, 382 insertions(+), 220 deletions(-) diff --git a/lam/help/help.inc b/lam/help/help.inc index 94626e15..0eda9978 100644 --- a/lam/help/help.inc +++ b/lam/help/help.inc @@ -23,6 +23,7 @@ $Id$ LDAP Account Manager help topics. */ + $helpArray = array ( // 0 - 99 // any developer @@ -148,7 +149,131 @@ $helpArray = array ( "370" => array ("ext" => "FALSE", "Headline" => _("Profile Editor - Primary Group"), "Text" => _("This is primary group for the Samba machine account.")), "371" => array ("ext" => "FALSE", "Headline" => _("Profile Editor - Domain"), - "Text" => _("This is the Windows domain name.")) + "Text" => _("This is the Windows domain name.")), + "400" => array ("ext" => "FALSE", "Headline" => _("Username"), + "Text" => _("Username of the user which should be created. Valid characters are: a-z,0-9, .-_. Lam doesn't allow a number as first + character because it's impossible to create a homedirectory starting with a number. Lam doesn't allow capital letters A-Z because it + can cause several problems.")), + "401" => array ("ext" => "FALSE", "Headline" => _("UID Number"), + "Text" => _("If empty UID Number will be generated automaticly. Valid values are between ")."$_SESSION['config']->get_minUID()"._(" and ")."$_SESSION['config']->get_maxUID()"."."), + "402" => array ("ext" => "FALSE", "Headline" => _("Additional Groupmembership"), + "Text" => _("Can be left empty. Hold the CTRL-key to (de)select multiple groups.")), + "403" => array ("ext" => "FALSE", "Headline" => _("Home Directory"), + "Text" => _("$user and $group are replaced with username or primary groupname.")), + "404" => array ("ext" => "FALSE", "Headline" => _("Gecos"), + "Text" => _("User descriptopn. If left empty sur- and givename will be used.")), + "405" => array ("ext" => "FALSE", "Headline" => _("Login shell"), + "Text" => _("To disable login use /bin/false.")), + "406" => array ("ext" => "FALSE", "Headline" => _("Primary Group"), + "Text" => _("The Primary Group the user should be member of.")), + "407" => array ("ext" => "FALSE", "Headline" => _("Groupname"), + "Text" => _("Groupname of the group which should be created. Valid characters are: a-z,0-9, .-_. Lam doesn't allow a number as first + character because it's impossible to create a homedirectory starting with a number. Lam doesn't allow capital letters A-Z because it + can cause several problems.")), + "408" => array ("ext" => "FALSE", "Headline" => _("GID Number"), + "Text" => _("If empty GID Number will be generated automaticly. Valid values are between ")."$_SESSION['config']->get_minGID()"._(" and ")."$_SESSION['config']->get_maxGID()"."."), + "409" => array ("ext" => "FALSE", "Headline" => _("Gecos"), + "Text" => _("Group descriptopn. If left empty groupname will be used.")), + "410" => array ("ext" => "FALSE", "Headline" => _("Hostname"), + "Text" => _("Groupname of the group which should be created. Valid characters are: a-z,0-9, .-_$. Lam doesn't allow a number as first + character because it's impossible to create a homedirectory starting with a number. Lam doesn't allow capital letters A-Z because it + can cause several problems. Hostnames are always ending with $. If last character isn't $ it will be added.")), + "411" => array ("ext" => "FALSE", "Headline" => _("UID Number"), + "Text" => _("If empty UID Number will be generated automaticly. Valid values are between ")."$_SESSION['config']->get_minMachine()"._(" and ")."$_SESSION['config']->get_maxMachine()"."."), + "412" => array ("ext" => "FALSE", "Headline" => _("Primary Group"), + "Text" => _("The Prmary Group the host should be member of.")), + "413" => array ("ext" => "FALSE", "Headline" => _("Gecos"), + "Text" => _("Host descriptopn. If left empty hostname will be used.")), + "414" => array ("ext" => "FALSE", "Headline" => _("Password Warn"), + "Text" => _("Days before password is to expire that user is warned of pending password expiration. Value must be 0<.")), + "415" => array ("ext" => "FALSE", "Headline" => _("Password Expire"), + "Text" => _("Number of days a user can login even his password has expired. -1=always")), + "416" => array ("ext" => "FALSE", "Headline" => _("Maximum Passwordage"), + "Text" => _("Number of days after a user has to change his password again Value must be 0<.")), + "417" => array ("ext" => "FALSE", "Headline" => _("Minimum Passwordage"), + "Text" => _("Number of days a user has to wait until he\'s allowed to change his password again. Value must be 0<.")), + "418" => array ("ext" => "FALSE", "Headline" => _("Expire date"), + "Text" => _("Account expire date.")), + "419" => array ("ext" => "FALSE", "Headline" => _("Password Warn"), + "Text" => _("Days before password is to expire that host is warned of pending password expiration. Value must be 0<.")), + "420" => array ("ext" => "FALSE", "Headline" => _("Password Expire"), + "Text" => _("Number of days a host can login even his password has expired. -1=always")), + "421" => array ("ext" => "FALSE", "Headline" => _("Maximum Passwordage"), + "Text" => _("Number of days after a host has to change his password again Value must be 0< and should be higher as the value on client-side.")), + "422" => array ("ext" => "FALSE", "Headline" => _("Minimum Passwordage"), + "Text" => _("Number of days a host has to wait until he\'s allowed to change his password again. Value must be 0<.")), + "423" => array ("ext" => "FALSE", "Headline" => _("Expire Date"), + "Text" => _("Account expire date.")), + "424" => array ("ext" => "FALSE", "Headline" => _(""), + "Text" => _("")), + "425" => array ("ext" => "FALSE", "Headline" => _(""), + "Text" => _("")), + "426" => array ("ext" => "FALSE", "Headline" => _(""), + "Text" => _("")), + "427" => array ("ext" => "FALSE", "Headline" => _(""), + "Text" => _("")), + "428" => array ("ext" => "FALSE", "Headline" => _(""), + "Text" => _("")), + "429" => array ("ext" => "FALSE", "Headline" => _(""), + "Text" => _("")), + "430" => array ("ext" => "FALSE", "Headline" => _(""), + "Text" => _("")), + "431" => array ("ext" => "FALSE", "Headline" => _(""), + "Text" => _("")), + "432" => array ("ext" => "FALSE", "Headline" => _(""), + "Text" => _("")), + "433" => array ("ext" => "FALSE", "Headline" => _(""), + "Text" => _("")), + "434" => array ("ext" => "FALSE", "Headline" => _(""), + "Text" => _("")), + "435" => array ("ext" => "FALSE", "Headline" => _(""), + "Text" => _("")), + "436" => array ("ext" => "FALSE", "Headline" => _(""), + "Text" => _("")), + "437" => array ("ext" => "FALSE", "Headline" => _(""), + "Text" => _("")), + "438" => array ("ext" => "FALSE", "Headline" => _(""), + "Text" => _("")), + "439" => array ("ext" => "FALSE", "Headline" => _(""), + "Text" => _("")), + "440" => array ("ext" => "FALSE", "Headline" => _(""), + "Text" => _("")), + "441" => array ("ext" => "FALSE", "Headline" => _(""), + "Text" => _("")), + "442" => array ("ext" => "FALSE", "Headline" => _(""), + "Text" => _("")), + "443" => array ("ext" => "FALSE", "Headline" => _(""), + "Text" => _("")), + "444" => array ("ext" => "FALSE", "Headline" => _(""), + "Text" => _("")), + "445" => array ("ext" => "FALSE", "Headline" => _(""), + "Text" => _("")), + "446" => array ("ext" => "FALSE", "Headline" => _(""), + "Text" => _("")), + "447" => array ("ext" => "FALSE", "Headline" => _(""), + "Text" => _("")), + "448" => array ("ext" => "FALSE", "Headline" => _(""), + "Text" => _("")), + "449" => array ("ext" => "FALSE", "Headline" => _(""), + "Text" => _("")), + "450" => array ("ext" => "FALSE", "Headline" => _(""), + "Text" => _("")), + "451" => array ("ext" => "FALSE", "Headline" => _(""), + "Text" => _("")), + "452" => array ("ext" => "FALSE", "Headline" => _(""), + "Text" => _("")), + "453" => array ("ext" => "FALSE", "Headline" => _(""), + "Text" => _("")), + "454" => array ("ext" => "FALSE", "Headline" => _(""), + "Text" => _("")), + "455" => array ("ext" => "FALSE", "Headline" => _(""), + "Text" => _("")), + "456" => array ("ext" => "FALSE", "Headline" => _(""), + "Text" => _("")), + "457" => array ("ext" => "FALSE", "Headline" => _(""), + "Text" => _("")), + "458" => array ("ext" => "FALSE", "Headline" => _(""), + "Text" => _("")) /* This is a sample help entry. Just copy this line an modify the vakues between the [] brackets. Help text is located in the array: "[Helpnumber]" => array ("ext" => "FALSE", "Headline" => _("[Headline]"), "Text" => _("[Text]"), "SeeAlso" => "[SeeAlso link]"), diff --git a/lam/lib/account.inc b/lam/lib/account.inc index dc21cc47..67f0a5f7 100644 --- a/lam/lib/account.inc +++ b/lam/lib/account.inc @@ -547,7 +547,7 @@ function loaduser($dn) { // Will load all needed values from an existing account if ($attr['gecos'][0]) $return->general_gecos = $attr['gecos'][0]; if ($attr['description'][0]) $return->general_gecos = $attr['description'][0]; if ($attr['gidNumber'][0]) { - $result = ldap_search($_SESSION['ldap']->server(), $_SESSION['config']->get_GroupSuffix(), "objectclass=PosixGroup", array('uidNumber')); + $result = ldap_search($_SESSION['ldap']->server(), $_SESSION['config']->get_GroupSuffix(), "objectclass=PosixGroup", array('gidNumber', 'cn')); $entry = ldap_first_entry($_SESSION['ldap']->server(), $result); while ($entry) { $attr2 = ldap_get_attributes($_SESSION['ldap']->server(), $entry); @@ -555,7 +555,7 @@ function loaduser($dn) { // Will load all needed values from an existing account $entry = ldap_next_entry($_SESSION['ldap']->server(), $entry); } } - $result = ldap_search($_SESSION['ldap']->server(), $_SESSION['config']->get_GroupSuffix(), "objectclass=PosixGroup", array('memberUid')); + $result = ldap_search($_SESSION['ldap']->server(), $_SESSION['config']->get_GroupSuffix(), "objectclass=PosixGroup", array('memberUid', 'cn')); $entry = ldap_first_entry($_SESSION['ldap']->server(), $result); while ($entry) { $attr2 = ldap_get_attributes($_SESSION['ldap']->server(), $entry); @@ -590,7 +590,8 @@ function loaduser($dn) { // Will load all needed values from an existing account if ($attr['title'][0]) $return->personal_title = $attr['title'][0]; if ($attr['mail'][0]) $return->personal_mail = $attr['mail'][0]; if ($attr['telephoneNumber'][0]) $return->personal_telephoneNumber = $attr['telephoneNumber'][0]; - if ($attr['mobile'][0]) $return->personal_mobileTelephoneNumber = $attr['mobile'][0]; + if ($attr['mobilemobileTelephoneNumber'][0]) $return->personal_mobileTelephoneNumber = $attr['mobilemobileTelephoneNumber'][0]; + else if ($attr['mobile'][0]) $return->personal_mobileTelephoneNumber = $attr['mobile'][0]; if ($attr['facsimileTelephoneNumber'][0]) $return->personal_facsimileTelephoneNumber = $attr['facsimileTelephoneNumber'][0]; if ($attr['street'][0]) $return->personal_street = $attr['street'][0]; if ($attr['postalCode'][0]) $return->personal_postalCode = $attr['postalCode'][0]; @@ -621,7 +622,7 @@ function loadhost($dn) { // Will load all needed values from an existing account if ($attr['gecos'][0]) $return->general_gecos = $attr['gecos'][0]; if ($attr['description'][0]) $return->general_gecos = $attr['description'][0]; if ($attr['gidNumber'][0]) { - $result = ldap_search($_SESSION['ldap']->server(), $_SESSION['config']->get_GroupSuffix(), "objectclass=PosixGroup", array('uidNumber')); + $result = ldap_search($_SESSION['ldap']->server(), $_SESSION['config']->get_GroupSuffix(), "objectclass=PosixGroup", array('gidNumber', 'cn')); $entry = ldap_first_entry($_SESSION['ldap']->server(), $result); while ($entry) { $attr2 = ldap_get_attributes($_SESSION['ldap']->server(), $entry); @@ -629,7 +630,7 @@ function loadhost($dn) { // Will load all needed values from an existing account $entry = ldap_next_entry($_SESSION['ldap']->server(), $entry); } } - $result = ldap_search($_SESSION['ldap']->server(), $_SESSION['config']->get_GroupSuffix(), "objectclass=PosixGroup", array('memberUid')); + $result = ldap_search($_SESSION['ldap']->server(), $_SESSION['config']->get_GroupSuffix(), "objectclass=PosixGroup", array('memberUid', 'cn')); $entry = ldap_first_entry($_SESSION['ldap']->server(), $result); while ($entry) { $attr2 = ldap_get_attributes($_SESSION['ldap']->server(), $entry); @@ -713,7 +714,7 @@ function createuser($values) { // Will create the LDAP-Account if ($values->personal_title!='') $attr['title'] = $values->personal_title; if ($values->personal_mail!='') $attr['mail'] = $values->personal_mail; if ($values->personal_telephoneNumber!='') $attr['telephoneNumber'] = $values->personal_telephoneNumber; - if ($values->personal_mobileTelephoneNumber!='') $attr['mobile'] = $values->personal_mobileTelephoneNumber; + if ($values->personal_mobileTelephoneNumber!='') $attr['mobilemobileTelephoneNumber'] = $values->personal_mobileTelephoneNumber; if ($values->personal_facsimileTelephoneNumber!='') $attr['facsimileTelephoneNumber'] = $values->personal_facsimileTelephoneNumber; if ($values->personal_street!='') $attr['street'] = $values->personal_street; if ($values->personal_postalCode!='') $attr['postalCode'] = $values->personal_postalCode; @@ -763,16 +764,6 @@ function createuser($values) { // Will create the LDAP-Account setquotas($values->general_username,'user'); addhomedir($values->general_username); } - // Add user to groups - $result = ldap_search($_SESSION['ldap']->server(), 'cn='.$values->general_group.','.$_SESSION['config']->get_GroupSuffix(), "objectclass=posixGroup"); - $entry = ldap_first_entry($_SESSION['ldap']->server(), $result); - $group = ldap_get_attributes($_SESSION['ldap']->server(), $entry); - if ($group['memberUid']) array_shift($group['memberUid']); - if (! in_array($values->general_username, $group)) { - $toadd['memberUid'] = $values->general_username; - $success = ldap_mod_add($_SESSION['ldap']->server(), 'cn='.$values->general_group.','.$_SESSION['config']->get_GroupSuffix(), $toadd); - if (!$success) return 4; - } // Add User to Additional Groups if ($values->general_groupadd) foreach ($values->general_groupadd as $group2) { @@ -864,9 +855,9 @@ function modifyuser($values,$values_old) { // Will modify the LDAP-Account if (($values->personal_telephoneNumber != $values_old->personal_telephoneNumber) && ($values->personal_telephoneNumber =='')) $attr_rem['telephoneNumber'] = $values_old->personal_telephoneNumber; if (($values->personal_mobileTelephoneNumber != $values_old->personal_mobileTelephoneNumber) && ($values->personal_mobileTelephoneNumber!='')) - $attr['mobiler'] = $values->personal_mobileTelephoneNumber; + $attr['mobileTelephoneNumber'] = $values->personal_mobileTelephoneNumber; if (($values->personal_mobileTelephoneNumber != $values_old->personal_mobileTelephoneNumber) && ($values->personal_mobileTelephoneNumber=='')) - $attr_rem['mobile'] = $values_old->personal_mobileTelephoneNumber; + $attr_rem['mobilemobileTelephoneNumber'] = $values_old->personal_mobileTelephoneNumber; if (($values->personal_facsimileTelephoneNumber != $values_old->personal_facsimileTelephoneNumber) && ($values->personal_facsimileTelephoneNumber!='')) $attr['facsimileTelephoneNumber'] = $values->personal_facsimileTelephoneNumber; if (($values->personal_facsimileTelephoneNumber != $values_old->personal_facsimileTelephoneNumber) && ($values->personal_facsimileTelephoneNumber=='')) @@ -927,12 +918,7 @@ function modifyuser($values,$values_old) { // Will modify the LDAP-Account } if (!$success) return 5; // Write Groupmemberchips - if ($values->general_groupadd) { - $allgroups = $values->general_groupadd; - if (!in_array($values->general_group, $allgroups)) $allgroups[] = $values->general_group; - } - else $allgroups[0] = $values->general_group; - $result = ldap_search($_SESSION['ldap']->server(), $_SESSION['config']->get_GroupSuffix(), 'objectClass=PosixGroup'); + $result = ldap_search($_SESSION['ldap']->server(), $_SESSION['config']->get_GroupSuffix(), 'objectClass=PosixGroup', array('memberUid', 'cn')); $entry = ldap_first_entry($_SESSION['ldap']->server(), $result); while ($entry) { $modifygroup=0; @@ -940,13 +926,13 @@ function modifyuser($values,$values_old) { // Will modify the LDAP-Account if ($attr2['memberUid']) { array_shift($attr2['memberUid']); foreach ($attr2['memberUid'] as $nam) { - if ( ($nam==$values->general_username) && !in_array($nam, $allgroups)) { + if ( ($nam==$values->general_username) && !in_array($attr2['cn'][0], $values->general_groupadd)) { $todelete['memberUid'] = $nam; $success = ldap_mod_del($_SESSION['ldap']->server(), ldap_get_dn($_SESSION['ldap']->server(), $entry) ,$todelete); if (!$success) return 5; } } - if (!in_array($values->general_username, $attr2['memberUid']) && in_array($attr2['cn'][0], $allgroups)) { + if (!in_array($values->general_username, $attr2['memberUid']) && in_array($attr2['cn'][0], $values->general_groupadd) && ($attr2['cn'][0]!=$values->general_group)) { $toadd['memberUid'] = $attr2['memberUid']; $toadd['memberUid'][] = $values->general_username; $success = ldap_mod_replace($_SESSION['ldap']->server(), ldap_get_dn($_SESSION['ldap']->server(), $entry), $toadd); @@ -954,7 +940,7 @@ function modifyuser($values,$values_old) { // Will modify the LDAP-Account } } else { - if (in_array($attr2['cn'][0], $allgroups)) { + if (in_array($attr2['cn'][0], $values->general_groupadd) && ($attr2['cn'][0]!=$values->general_group)) { $toadd['memberUid'] = $values->general_username; $success = ldap_mod_add($_SESSION['ldap']->server(), ldap_get_dn($_SESSION['ldap']->server(), $entry), $toadd); if (!$success) return 5; @@ -1022,16 +1008,6 @@ function createhost($values) { // Will create the LDAP-Account if ($values->smb_domain!='') $attr['domain'] = $values->smb_domain; // sambaAccount_may $success = ldap_add($_SESSION['ldap']->server(),$values->general_dn, $attr); if (!$success) return 4; - // Add host to groups - $result = ldap_search($_SESSION['ldap']->server(), 'cn='.$values->general_group.','.$_SESSION['config']->get_GroupSuffix(), "objectclass=posixGroup"); - $entry = ldap_first_entry($_SESSION['ldap']->server(), $result); - $group = ldap_get_attributes($_SESSION['ldap']->server(), $entry); - if ($group['memberUid']) array_shift($group['memberUid']); - if (! in_array($values->general_username, $group)) { - $toadd['memberUid'] = $values->general_username; - $success = ldap_mod_add($_SESSION['ldap']->server(), 'cn='.$values->general_group.','.$_SESSION['config']->get_GroupSuffix(), $toadd); - if (!$success) return 4; - } // Add Host to Additional Groups if ($values->general_groupadd) foreach ($values->general_groupadd as $group2) { @@ -1137,12 +1113,6 @@ function modifyhost($values,$values_old) { // Will modify the LDAP-Account if ($success) $success = ldap_mod_replace($_SESSION['ldap']->server(),$values->general_dn, $attr); } if (!$success) return 5; - // Write Groupmemberchips - if ($values->general_groupadd) { - $allgroups = $values->general_groupadd; - if (!in_array($values->general_group, $allgroups)) $allgroups[] = $values->general_group; - } - else $allgroups[0] = $values->general_group; $result = ldap_search($_SESSION['ldap']->server(), $_SESSION['config']->get_GroupSuffix(), 'objectClass=PosixGroup'); $entry = ldap_first_entry($_SESSION['ldap']->server(), $result); while ($entry) { @@ -1151,13 +1121,13 @@ function modifyhost($values,$values_old) { // Will modify the LDAP-Account if ($attr2['memberUid']) { array_shift($attr2['memberUid']); foreach ($attr2['memberUid'] as $nam) { - if ( ($nam==$values->general_username) && !in_array($nam, $allgroups)) { + if ( ($nam==$values->general_username) && !in_array($nam, $values->general_groupadd)) { $todelete['memberUid'] = $nam; $success = ldap_mod_del($_SESSION['ldap']->server(), ldap_get_dn($_SESSION['ldap']->server(), $entry) ,$todelete); if (!$success) return 5; } } - if (!in_array($values->general_username, $attr2['memberUid']) && in_array($attr2['cn'][0], $allgroups)) { + if (!in_array($values->general_username, $attr2['memberUid']) && in_array($attr2['cn'][0], $values->general_groupadd)) { $toadd['memberUid'] = $attr2['memberUid']; $toadd['memberUid'][] = $values->general_username; $success = ldap_mod_replace($_SESSION['ldap']->server(), ldap_get_dn($_SESSION['ldap']->server(), $entry), $toadd); @@ -1165,7 +1135,7 @@ function modifyhost($values,$values_old) { // Will modify the LDAP-Account } } else { - if (in_array($attr2['cn'][0], $allgroups)) { + if (in_array($attr2['cn'][0], $values->general_groupadd)) { $toadd['memberUid'] = $values->general_username; $success = ldap_mod_add($_SESSION['ldap']->server(), ldap_get_dn($_SESSION['ldap']->server(), $entry), $toadd); if (!$success) return 5; diff --git a/lam/templates/account.php b/lam/templates/account.php index f88599dd..88271f67 100644 --- a/lam/templates/account.php +++ b/lam/templates/account.php @@ -23,21 +23,28 @@ $Id$ LDAP Account Manager displays table for creating or modifying accounts in LDAP */ -include_once('../lib/account.inc'); // File with custom functions +include_once('../lib/account.inc'); // File with all account-funtions include_once('../lib/config.inc'); // File with configure-functions include_once('../lib/ldap.inc'); // LDAP-functions include_once('../lib/profiles.inc'); // functions to load and save profiles include_once('../lib/status.inc'); // Return error-message include_once('../lib/pdf.inc'); // Return a pdf-file - $error = "0"; initvars($_GET['type'], $_GET['DN']); // Initialize all needed vars -switch ($_POST['select']) { +switch ($_POST['select']) { // Select which part of page should be loaded and check values + // general = startpage, general account paramters + // unix = page with all shadow-options and password + // samba = page with all samba-related parameters e.g. smbpassword + // quota = page with all quota-related parameters e.g. hard file quota + // personal = page with all personal-related parametergs, e.g. phone number + // final = last page shown before account is created/modified + // if account is modified commands might be ran are shown + // finish = page shown after account has been created/modified case 'general': - if (!$_POST['load']) { // No Profile was loaded - // Write all values in temporary object + // Write all general values into $_SESSION['account'] if no profile should be loaded + if (!$_POST['load']) { if ($_POST['f_general_username']) $_SESSION['account']->general_username = $_POST['f_general_username']; else $_SESSION['account']->general_username = $_POST['f_general_username']; if ($_POST['f_general_surname']) $_SESSION['account']->general_surname = $_POST['f_general_surname']; @@ -47,13 +54,14 @@ switch ($_POST['select']) { if ($_POST['f_general_uidNumber']) $_SESSION['account']->general_uidNumber = $_POST['f_general_uidNumber']; else $_SESSION['account']->general_uidNumber = ""; if ($_POST['f_general_group']) $_SESSION['account']->general_group = $_POST['f_general_group']; - if ($_POST['f_general_groupadd']) $_SESSION['account']->general_groupadd = $_POST['f_general_groupadd']; + if ($_POST['f_general_groupadd']) $_SESSION['account']->general_groupadd = $_POST['f_general_groupadd']; + else $_SESSION['account']->general_groupadd = ''; if ($_POST['f_general_homedir']) $_SESSION['account']->general_homedir = $_POST['f_general_homedir']; else $_SESSION['account']->general_homedir = ""; if ($_POST['f_general_shell']) $_SESSION['account']->general_shell = $_POST['f_general_shell']; if ($_POST['f_general_gecos']) $_SESSION['account']->general_gecos = $_POST['f_general_gecos']; else $_SESSION['account']->general_gecos = ""; - // Check Values + // Check if values are OK and set automatic values. if not error-variable will be set if ($_SESSION['account_old']) $values = checkglobal($_SESSION['account'], $_SESSION['type2'], $_SESSION['account_old']); // account.inc else $values = checkglobal($_SESSION['account'], $_SESSION['type2']); // account.inc if (is_object($values)) { @@ -61,7 +69,7 @@ switch ($_POST['select']) { if ($val) $_SESSION['account']->$key = $val; } else $error = $values; - // Check which part Site should be displayd + // Check which part Site should be displayed next if ($_POST['next'] && ($error=="0")) switch ($_SESSION['type2']) { case 'user': $select_local = 'unix'; break; @@ -71,10 +79,9 @@ switch ($_POST['select']) { } break; case 'unix': - // Write all values in temporary object + // Write all general values into $_SESSION['account'] if ($_POST['f_unix_password']) $_SESSION['account']->unix_password = $_POST['f_unix_password']; else $_SESSION['account']->unix_password = ''; - if ($_POST['genpass']) { $_SESSION['account']->unix_password = genpasswd(); } if ($_POST['f_unix_password_no']) $_SESSION['account']->unix_password_no = true; else $_SESSION['account']->unix_password_no = false; if ($_POST['f_unix_pwdwarn']) $_SESSION['account']->unix_pwdwarn = $_POST['f_unix_pwdwarn']; @@ -90,20 +97,27 @@ switch ($_POST['select']) { if ($_POST['f_unix_pwdexpire_yea']) $_SESSION['account']->unix_pwdexpire_yea = $_POST['f_unix_pwdexpire_yea']; if ($_POST['f_unix_deactivated']) $_SESSION['account']->unix_deactivated = $_POST['f_unix_deactivated']; else $_SESSION['account']->unix_deactivated = false; - // Check Values - // Check which part Site should be displayd - if ($_POST['genpass']) $select_local = 'unix'; + if ($_POST['genpass']) { + // Generate a random password if generate-button was pressed + $_SESSION['account']->unix_password = genpasswd(); + // Keep unix-page acitve + $select_local = 'unix'; + } + // Check if values are OK and set automatic values. if not error-variable will be set else $error = checkunix($_SESSION['account'], $_SESSION['type2']); // account.inc + // Check which part Site should be displayd + // Reset password if reset button was pressed. Button only vissible if account should be modified if ($_POST['respass']) { $_SESSION['account']->unix_password_no=true; $_SESSION['account']->smb_password_no=true; } - if (($_POST['next']) && ($error=="0")) $select_local = 'samba'; - else $select_local = 'unix'; + // Check which part Site should be displayed next if ($_POST['back']) $select_local = 'general'; + else if (($_POST['next']) && ($error=="0")) $select_local = 'samba'; + else $select_local = 'unix'; break; case 'samba': - // Write all values in temporary object + // Write all general values into $_SESSION['account'] if ($_POST['f_smb_password']) $_SESSION['account']->smb_password = $_POST['f_smb_password']; else $_SESSION['account']->smb_password = ""; if ($_POST['f_smb_password_no']) $_SESSION['account']->smb_password_no = true; @@ -131,25 +145,25 @@ switch ($_POST['select']) { else $_SESSION['account']->smb_flagsD = false; if ($_POST['f_smb_flagsX']) $_SESSION['account']->smb_flagsX = $_POST['f_smb_flagsX']; else $_SESSION['account']->smb_flagsX = false; - // Check Values + // Check if values are OK and set automatic values. if not error-variable will be set $values = checksamba($_SESSION['account'], $_SESSION['type2']); // account.inc if (is_object($values)) { while (list($key, $val) = each($values)) // Set only defined values if ($val) $_SESSION['account']->$key = $val; } else $error = $values; - // Check which part Site should be displayd + // Check which part Site should be displayed next if ($_POST['back']) $select_local = 'unix'; - if ($_POST['next']) { + else if ($_POST['next']) if ($error=="0") switch ($_SESSION['type2']) { case 'user': $select_local = 'quota'; break; case 'host': $select_local = 'final'; break; } else $select_local = 'samba'; - } break; case 'quota': + // Write all general values into $_SESSION['account'] $i=0; while ($_SESSION['account']->quota[$i][0]) { $_SESSION['account']->quota[$i][2] = $_POST['f_quota_'.$i.'_2']; @@ -158,28 +172,29 @@ switch ($_POST['select']) { $_SESSION['account']->quota[$i][7] = $_POST['f_quota_'.$i.'_7']; $i++; } + // Check if values are OK and set automatic values. if not error-variable will be set $values = checkquota($_SESSION['account'], $_SESSION['type2']); // account.inc if (is_object($values)) { while (list($key, $val) = each($values)) // Set only defined values if ($val) $_SESSION['account']->$key = $val; } else $error = $values; - // Check which part Site should be displayd + // Check which part Site should be displayed next if ($_POST['back']) switch ($_SESSION['type2']) { case 'user': $select_local = 'samba'; break; case 'group': $select_local = 'general'; break; } - if ($_POST['next']) { + else if ($_POST['next']) if ($error=="0") switch ($_SESSION['type2']) { case 'user': $select_local = 'personal'; break; case 'group': $select_local = 'final'; break; } else $select_local = 'quota'; - } break; case 'personal': + // Write all general values into $_SESSION['account'] if ($_POST['f_personal_title']) $_SESSION['account']->personal_title = $_POST['f_personal_title']; else $_SESSION['account']->personal_title = ""; if ($_POST['f_personal_mail']) $_SESSION['account']->personal_mail = $_POST['f_personal_mail']; @@ -198,19 +213,24 @@ switch ($_POST['select']) { else $_SESSION['account']->personal_postalAddress = ""; if ($_POST['f_personal_employeeType']) $_SESSION['account']->personal_employeeType = $_POST['f_personal_employeeType']; else $_SESSION['account']->personal_employeeType = ""; - // Check which part Site should be displayd + // Check if values are OK and set automatic values. if not error-variable will be set $values = checkpersonal($_SESSION['account'], $_SESSION['type2']); // account.inc if (is_object($values)) { while (list($key, $val) = each($values)) // Set only defined values if ($val) $_SESSION['account']->$key = $val; } else $error = $values; - if ($_POST['back'] && ($error=="0")) $select_local = 'quota'; - if ($_POST['next'] && ($error=="0")) $select_local = 'final'; + // Check which part Site should be displayed next + if ($_POST['back']) $select_local = 'quota'; + else if ($_POST['next']) + if ($error=="0") $select_local = 'final'; + else $select_local = 'personal'; break; case 'final': + // Write all general values into $_SESSION['account'] if ($_POST['f_final_changegids']) $_SESSION['final_changegids'] = $_POST['f_final_changegids'] ; - if ($_POST['back'] && ($error=="0")) + // Check which part Site should be displayed next + if ($_POST['back']) switch ($_SESSION['type2']) { case 'user': $select_local = 'personal'; break; case 'group': $select_local = 'quota'; break; @@ -218,6 +238,7 @@ switch ($_POST['select']) { } break; case 'finish': + // Check if pdf-file should be created if ($_POST['outputpdf']) createpdf($_SESSION['account']); break; } @@ -225,6 +246,7 @@ switch ($_POST['select']) { if ( $_POST['create'] ) { // Create-Button was pressed + // Create or modify an account switch ($_SESSION['type2']) { case 'user': if ($_SESSION['account_old']) $result = modifyuser($_SESSION['account'],$_SESSION['account_old']); @@ -245,51 +267,60 @@ if ( $_POST['create'] ) { // Create-Button was pressed } +// Set selected page to general if no page was defined. should only true if account.php wasn't called by itself if (!$select_local) $select_local='general'; +// Reset variables if recreate-button was pressed if ($_POST['createagain']) { $select_local='general'; $_SESSION['account']=""; } +// Set selected page to backmain (Back to main listmenu) if ($_POST['backmain']) { $select_local='backmain'; } - +// Set selected page to load (load profile) if ($_POST['load']) $select_local='load'; +// Set selected page to save (save profile) if ($_POST['save']) $select_local='save'; // Write HTML-Header and part of Table -echo ''; -echo ''; -echo _('Create new Account'); -echo ' - - - - '; +echo "\n"; +echo ""; +echo _("Create new Account"); +echo "\n + \n + \n + \n + "; switch ($select_local) { + // backmain = back to lists + // load = load profile + // save = save profile case 'backmain': + // unregister sessionvar and select which list should be shown if (session_is_registered("shelllist")) session_unregister("shelllist"); if (session_is_registered("account")) session_unregister("account"); if (session_is_registered("account_old")) session_unregister("account_old"); switch ( $_SESSION['type2'] ) { case 'user' : if (session_is_registered("type2")) session_unregister("type2"); - echo ''; + echo "\n"; break; case 'group' : if (session_is_registered("type2")) session_unregister("type2"); - echo ''; + echo "\n"; break; case 'host' : if (session_is_registered("type2")) session_unregister("type2"); - echo ''; + echo "\n"; break; } break; case 'load': + // load profile switch ( $_SESSION['type2'] ) { case 'user': $_SESSION['account'] = loadUserProfile($_POST['f_general_selectprofile']); @@ -301,9 +332,11 @@ switch ($select_local) { $_SESSION['account'] = loadGroupProfile($_POST['f_general_selectprofile']); break; } + // select general page after group has been loaded $select_local='general'; break; case 'save': + // save profile switch ( $_SESSION['type2'] ) { case 'user': saveUserProfile($_SESSION['account'], $_POST['f_finish_safeProfile']); @@ -315,54 +348,73 @@ switch ($select_local) { saveGroupProfile($_SESSION['account'], $_POST['f_finish_safeProfile']); break; } + // select last page displayed before user is created $select_local='final'; break; } - echo ' -
'; - if ($error != "0") StatusMessage('ERROR', _('Invalid Value!'), $error); - echo ''; + echo "\n"; + echo "\n"; + if ($error != "0") StatusMessage("ERROR", _("Invalid Value!"), $error); + echo "\n"; -switch ($select_local) { +switch ($select_local) { // Select which part of page will be loaded + // general = startpage, general account paramters + // unix = page with all shadow-options and password + // samba = page with all samba-related parameters e.g. smbpassword + // quota = page with all quota-related parameters e.g. hard file quota + // personal = page with all personal-related parametergs, e.g. phone number + // final = last page shown before account is created/modified + // if account is modified commands might be ran are shown + // finish = page shown after account has been created/modified case 'general': // General Account Settings + // load list of all groups $groups = findgroups(); + // Show page info echo ''; + echo "\n"; switch ( $_SESSION['type2'] ) { case 'user': + // load list of profiles $profilelist = getUserProfiles(); + // Create HTML-page echo '\n'."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''; + echo ''."\n".''."\n"; break; case 'unix': // Unix Password Settings echo ''; + echo ''."\n".''; switch ( $_SESSION['type2'] ) { case 'user' : echo ''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''; + echo '>'."\n"; break; case 'host' : echo ''; echo ''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''; + echo '>'."\n"; break; } echo ''."\n".''."\n".''; + '."\n"; break; case 'samba': // Samba Settings - echo ''; + echo ''."\n"; switch ( $_SESSION['type2'] ) { case 'user': echo '
'; echo _('General Properties'); - echo '
'; - echo _('Username'); - echo ' - -
'; + echo _('Username*'); + echo "". + ' + + '._('Help').' +
'; echo _('UID Number'); - echo ' + echo ' - '; - echo _('If empty UID Number will be generated automaticly.'); - echo '
'; - echo _('Surname'); - echo ' + + '._('Help').' +
'; + echo _('Surname*'); + echo ' -
'; - echo _('Given name'); - echo ' +
'; + echo _('Given name*'); + echo ' -
'; +
'; echo _('Primary Group'); - echo '
'; + echo ' + '._('Help').' +
'; echo _('Additional Groupmembership'); - echo ''; - echo _('Can be left empty. Hold the CTRL-key to select multiple groups.'); - echo '
'; + echo ' + '._('Help').' +
'; echo _('Home Directory'); - echo ' - '; - echo _('$user and $group are replaced with username or primary groupname.'); - echo '
'; + echo ' + + '._('Help').' +
'; echo _('Gecos'); - echo ' - '; - echo _('User descriptopn. If left empty sur- and givename will be used.'); - echo '
'; + echo ' + + '._('Help').' +
'; echo _('Login Shell'); - echo ''; - echo _('To disable login use /bin/false.'); - echo '
+ '._('Help').' +
- - '; + + '; break; case 'group': + // load list of profiles $profilelist = getGroupProfiles(); + // Create HTML-page echo '
'; echo _('Groupname'); - echo ' + echo ' -
'; + + '._('Help').' +
'; echo _('GID Number'); - echo ' + echo ' - '; - echo _('If empty GID Number will be generated automaticly.'); - echo '
'; + + '._('Help').' +
'; echo _('Gecos'); - echo ' - '; - echo _('User descriptopn. If left empty groupname will be used.'); - echo '
+ + '._('Help').' +
- - '; + + '; break; case 'host': + // load list of profiles $profilelist = getHostProfiles(); + // Create HTML-page echo '
'; echo _('Hostname'); - echo ' + echo ' -
'; + + '._('Help').' +
'; echo _('UID Number'); - echo ' + echo ' - '; - echo _('If empty UID Number will be generated automaticly.'); - echo '
'; + + '._('Help').' +
'; echo _('Primary Group'); - echo '
'; + echo ' + '._('Help').' +
'; echo _('Additional Groupmembership'); - echo ''; - echo _('Can be left empty. Hold the CTRL-key to select multiple groups.'); - echo '
'; + echo ' + '._('Help').' +
'; echo _('Gecos'); echo ' - '; - echo _('Host descriptopn. If left empty hostname will be used.'); - echo '
+ '._('Help').' +
- - '; + + '; break; } - echo ' - -
+ +
'; echo _('Unix Properties'); - echo '
'; echo _('Password'); - echo ' + echo ' - + -
'; +
'; echo _('Use no Password.'); - echo ''."\n".'unix_password_no) echo ' checked '; - echo '>
'; + echo '>
'; echo _('Password Warn'); - echo ' - '; - echo _('Number of days a user will be warned when password will expire. Value must be 0<.'); - echo '
'; + echo ' + + '._('Help').' +
'; echo _('Password Expire'); - echo ' - '; - echo _('Number of days a user can login even his password has expired. -1=always'); - echo '
'; + echo ' + + '._('Help').' +
'; echo _('Maximum Passwordage'); - echo ' - '; - echo _('Number of days after a user has to change his password again Value must be 0<.'); - echo '
'; + echo ' + + '._('Help').' +
'; echo _('Minimum Passwordage'); - echo ' - '; - echo _('Number of days a user has to wait until he\'s allowed to change his password again. Value must be 0<.'); - echo '
'; + echo ' + + '._('Help').' +
'; echo _('Expire Date'); - echo ''; - echo _('Account expire date.'); - echo '
'; + echo ' + '._('Help').' +
'; echo _('Account deactivated'); - echo ''."\n".'unix_deactivated) echo ' checked '; - echo '>
'; echo _('Password'); - echo ''; + echo ''; if ($_SESSION['account_old']) { echo ''; } - echo '
'; + echo '
'; echo _('Password Warn'); - echo ' - '; - echo _('Number of host a user will be warned when password will expire. Value must be 0<.'); - echo '
'; + echo ' + + '._('Help').' +
'; echo _('Password Expire'); - echo ' - '; - echo _('Number of days a host can login even his password has expired. -1=always'); - echo '
'; + echo ' + + '._('Help').' +
'; echo _('Maximum Passwordage'); - echo ' - '; - echo _('Number of days after a host has to change his password again Value must be 0< and should be higher as the value on client-side.'); - echo '
'; + echo ' + + '._('Help').' +
'; echo _('Minimum Passwordage'); - echo ' - '; - echo _('Number of days a user has to wait until he\'s allowed to change his password again. Value must be 0<.'); - echo '
'; + echo ' + + '._('Help').' +
'; echo _('Expire Date'); - echo ''; - echo _('Account expire date.'); - echo '
'; + echo ' + '._('Help').' +
'; echo _('Account deactivated'); - echo ''."\n".'unix_deactivated) echo ' checked '; - echo '>
- + -
'; echo _('Samba Properties'); echo '
'; echo _('Samba Properties'); echo '
'; echo _('Samba Password'); echo ' - smb_useunixpwd) echo ' checked '; echo '>'; echo _('Use Unix-Password'); diff --git a/lam/templates/delete.php b/lam/templates/delete.php index f5872058..8c6ec2d5 100644 --- a/lam/templates/delete.php +++ b/lam/templates/delete.php @@ -103,14 +103,17 @@ if ($_POST['delete_yes']) { case 'group': $temp=explode(',', $dn); $groupname = str_replace('cn=', '', $temp[0]); - $result = ldap_search($_SESSION['ldap']->server(), $dn, 'objectClass=*'); - if (!$result) $error = _('Could not delete group: ').$dn; + $result = ldap_search($_SESSION['ldap']->server(), $dn, 'objectClass=*', array('gidNumber'); $entry = ldap_first_entry($_SESSION['ldap']->server(), $result); - $attr = ldap_get_attributes($_SESSION['ldap']->server(), $entry); - if ($attr['memberUid']) $error = _('Could not delete group. Still users in group: ').$dn; - else { + while ($entry) { + $attr2 = ldap_get_attributes($_SESSION['ldap']->server(), $entry); + if ($attr2['gidNumber']==getgid($groupname)) $error = _('Could not delete group. Still users in group: ').$dn; + $entry = ldap_next_entry($_SESSION['ldap']->server(), $entry); + } + if (!$error) { if ($_SESSION['config']->scriptServer) remquotas($groupname, $_POST['type5']); $success = ldap_delete($_SESSION['ldap']->server(), $dn); + if (!$success) $error = _('Could not delete group: ').$dn; } break; }