general_dn = substr($_SESSION['account']->general_dn, strpos($_SESSION['account']->general_dn, ',')+1); $_SESSION['final_changegids'] = ''; } else { $_SESSION['account'] = loadGroupProfile('default'); $_SESSION['account'] ->type = 'group'; if (isset($_SESSION['account_old'])) unset($_SESSION['account_old']); } } else if (count($_POST)==0) { // Startcondition. groupedit.php was called from outside $_SESSION['account'] = loadGroupProfile('default'); $_SESSION['account'] ->type = 'group'; if (isset($_SESSION['account_old'])) unset($_SESSION['account_old']); } switch ($_POST['select']) { // Select which part of page should be loaded and check values // general = startpage, general account paramters // 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 'groupmembers': do { // X-Or, only one if() can be true if (isset($_POST['users']) && isset($_POST['add'])) { // Add users to list // Add new user $_SESSION['account']->unix_memberUid = array_merge($_SESSION['account']->unix_memberUid, $_POST['users']); // remove doubles $_SESSION['account']->unix_memberUid = array_flip($_SESSION['account']->unix_memberUid); array_unique($_SESSION['account']->unix_memberUid); $_SESSION['account']->unix_memberUid = array_flip($_SESSION['account']->unix_memberUid); // sort user sort($_SESSION['account']->unix_memberUid); // display groupmembers page break; } if (isset($_POST['members']) && isset($_POST['remove'])) { // remove users fromlist $_SESSION['account']->unix_memberUid = array_delete($_POST['members'], $_SESSION['account']->unix_memberUid); break; } } while(0); $select_local = 'groupmembers'; break; case 'general': // Write all general values into $_SESSION['account'] if no profile should be loaded if (!$_POST['load']) { $_SESSION['account']->general_dn = $_POST['f_general_suffix']; $_SESSION['account']->general_username = $_POST['f_general_username']; $_SESSION['account']->general_uidNumber = $_POST['f_general_uidNumber']; $_SESSION['account']->general_gecos = $_POST['f_general_gecos']; // Check if values are OK and set automatic values. if not error-variable will be set // Check if Groupname contains only valid characters if ( !ereg('^([a-z]|[0-9]|[.]|[-]|[_])*$', $_SESSION['account']->general_username)) $errors[] = array('ERROR', _('Groupname'), _('Groupname contains invalid characters. Valid characters are: a-z, 0-9 and .-_ !')); if ($_SESSION['account']->general_gecos=='') { $_SESSION['account']->general_gecos = $_SESSION['account']->general_username ; $errors[] = array('INFO', _('Gecos'), _('Inserted groupname in gecos-field.')); } // Create automatic groupaccount with number if original group already exists // Reset name to original name if new name is in use if (ldapexists($_SESSION['account'], 'group', $_SESSION['account_old']) && is_object($_SESSION['account_old'])) $_SESSION['account']->general_username = $_SESSION['account_old']->general_username; while ($temp = ldapexists($_SESSION['account'], 'group', $_SESSION['account_old'])) { // get last character of username $lastchar = substr($_SESSION['account']->general_username, strlen($_SESSION['account']->general_username)-1, 1); // Last character is no number if ( !ereg('^([0-9])+$', $lastchar)) $_SESSION['account']->general_username = $_SESSION['account']->general_username . '2'; else { $i=strlen($_SESSION['account']->general_username)-1; $mark = false; while (!$mark) { if (ereg('^([0-9])+$',substr($_SESSION['account']->general_username, $i, strlen($_SESSION['account']->general_username)-$i))) $i--; else $mark=true; } // increase last number with one $firstchars = substr($_SESSION['account']->general_username, 0, $i+1); $lastchars = substr($_SESSION['account']->general_username, $i+1, strlen($_SESSION['account']->general_username)-$i); $_SESSION['account']->general_username = $firstchars . (intval($lastchars)+1); } } if ($_SESSION['account']->general_username != $_POST['f_general_username']) $errors[] = array('WARN', _('Groupname'), _('Groupname already in use. Selected next free groupname.')); // Check if UID is valid. If none value was entered, the next useable value will be inserted $_SESSION['account']->general_uidNumber = checkid($_SESSION['account'], 'group', $_SESSION['account_old']); if (is_string($_SESSION['account']->general_uidNumber)) { // true if checkid has returned an error $errors[] = array('ERROR', _('ID-Number'), $_SESSION['account']->general_uidNumber); unset($return->general_uidNumber); } // Check if Name-length is OK. minLength=3, maxLength=20 if ( !ereg('.{3,20}', $_SESSION['account']->general_username)) $errors[] = array('ERROR', _('Name'), _('Name must contain between 3 and 20 characters.')); // Check if Name starts with letter if ( !ereg('^([a-z]|[A-Z]).*$', $_SESSION['account']->general_username)) $errors[] = array('ERROR', _('Name'), _('Name contains invalid characters. First character must be a letter')); } break; case 'samba': $samba3domains = $_SESSION['ldap']->search_domains($_SESSION[config]->get_domainSuffix()); foreach ($samba3domains as $domain) if ($_POST['f_smb_domain'] == $domain->name) $_SESSION['account']->smb_domain = $domain; $_SESSION['account']->smb_displayName = $_POST['f_smb_displayName']; if ($_SESSION['config']->is_samba3()) switch ($_POST['f_smb_mapgroup']) { case '*'._('Domain Guests'): $_SESSION['account']->smb_mapgroup = $_SESSION['account']->smb_domain->SID . "-" . '514'; break; case '*'._('Domain Users'): $_SESSION['account']->smb_mapgroup = $_SESSION['account']->smb_domain->SID . "-" . '513'; break; case '*'._('Domain Admins'): $_SESSION['account']->smb_mapgroup = $_SESSION['account']->smb_domain->SID . "-" . '512'; break; case $_SESSION['account']->general_username: $_SESSION['account']->smb_mapgroup = $_SESSION['account']->smb_domain->SID . "-". (2 * getgid($_SESSION['account']->general_username) + $_SESSION['account']->smb_domain->RIDbase +1); break; } else switch ($_POST['f_smb_mapgroup']) { case '*'._('Domain Guests'): $_SESSION['account']->smb_mapgroup = '514'; break; case '*'._('Domain Users'): $_SESSION['account']->smb_mapgroup = '513'; break; case '*'._('Domain Admins'): $_SESSION['account']->smb_mapgroup = '512'; break; case $_SESSION['account']->general_username: $_SESSION['account']->smb_mapgroup = (2 * getgid($_SESSION['account']->general_username) + 1001); break; } // Check if value is set if (($_SESSION['account']->smb_displayName=='') && isset($_SESSION['account']->general_gecos)) { $_SESSION['account']->smb_displayName = $_SESSION['account']->general_gecos; $errors[] = array('INFO', _('Display name'), _('Inserted gecos-field as display name.')); } 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']; $_SESSION['account']->quota[$i][3] = $_POST['f_quota_'.$i.'_3']; $_SESSION['account']->quota[$i][6] = $_POST['f_quota_'.$i.'_6']; $_SESSION['account']->quota[$i][7] = $_POST['f_quota_'.$i.'_7']; // Check if values are OK and set automatic values. if not error-variable will be set if (!ereg('^([0-9])*$', $_SESSION['account']->quota[$i][2])) $errors[] = array('ERROR', _('Block soft quota'), _('Block soft quota contains invalid characters. Only natural numbers are allowed')); if (!ereg('^([0-9])*$', $_SESSION['account']->quota[$i][3])) $errors[] = array('ERROR', _('Block hard quota'), _('Block hard quota contains invalid characters. Only natural numbers are allowed')); if (!ereg('^([0-9])*$', $_SESSION['account']->quota[$i][6])) $errors[] = array('ERROR', _('Inode soft quota'), _('Inode soft quota contains invalid characters. Only natural numbers are allowed')); if (!ereg('^([0-9])*$', $_SESSION['account']->quota[$i][7])) $errors[] = array('ERROR', _('Inode hard quota'), _('Inode hard quota contains invalid characters. Only natural numbers are allowed')); $i++; } break; case 'final': // Write all general values into $_SESSION['account'] if ($_POST['f_final_changegids']) $_SESSION['final_changegids'] = $_POST['f_final_changegids'] ; break; } // Write HTML-Header and part of Table echo $_SESSION['header']; echo "