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']); $_SESSION['account_old'] = false; } $values = getquotas($type); if (is_object($values)) { while (list($key, $val) = each($values)) // Set only defined values if (isset($val)) $_SESSION['account']->$key = $val; } } 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']); $_SESSION['account_old'] = false; } 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 $select_local = 'groupmembers'; break; } if (isset($_POST['members']) && isset($_POST['remove'])) { // remove users fromlist $_SESSION['account']->unix_memberUid = array_delete($_POST['members'], $_SESSION['account']->unix_memberUid); $select_local = 'groupmembers'; break; } } while(0); break; case 'general': // Write all general values into $_SESSION['account'] if no profile should be loaded if (!$_POST['load']) { // Set correct SID if GIS has changed if ($_SESSION['config']->samba3 == 'yes') if (isset($_SESSION['account_old']->general_uidNumber)) { if ($_SESSION['account']->general_uidNumber != $_POST['f_general_uidNumber']) { $temp = explode('-', $_SESSION['account']->smb_mapgroup); $SID = $temp[0].'-'.$temp[1].'-'.$temp[2].'-'.$temp[3].'-'.$temp[4].'-'.$temp[5].'-'.$temp[6]; if ( $temp[7]!='512' && $temp[7]!='513' && $temp[7]!='514' ) $_SESSION['account']->smb_mapgroup = $_SESSION['account']->smb_domain->SID . "-". (2 * $_POST['f_general_uidNumber'] + $_SESSION['account']->smb_domain->RIDbase +1); } } $_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 user 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']; 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; } // 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']; $i++; } // Check if values are OK and set automatic values. if not error-variable will be set $i=0; while ($_SESSION['account']->quota[$i][0]) { 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 "