general_dn = substr($account_new->general_dn, strpos($account_new->general_dn, ',')+1); $final_changegids = ''; } else if (count($_POST)==0) { // Startcondition. groupedit.php was called from outside $account_new = loadGroupProfile('default'); $account_new ->type = 'group'; if ($config_intern->scriptServer) { // load quotas from profile and check if they are valid $values = getquotas('group'); if (isset($account_new->quota[0])) { // check quotas from profile $i=0; // check quota settings while (isset($account_new->quota[$i])) { $found = (-1); for ($j=0; $jquota); $j++) if ($values->quota[$j][0]==$account_new->quota[$i][0]) $found = $j; if ($found==-1) unset($account_new->quota[$i]); else { $account_new->quota[$i][1] = $values->quota[$found][1]; $account_new->quota[$i][5] = $values->quota[$found][5]; $account_new->quota[$i][4] = $values->quota[$found][4]; $account_new->quota[$i][8] = $values->quota[$found][8]; $i++; } } $account_new->quota = array_values($account_new->quota); } else { // No quotas saved in profile if (is_object($values)) { while (list($key, $val) = each($values)) // Set only defined values if (isset($val)) $account_new->$key = $val; } } } unset($account_old); unset($_SESSION['account_'.$varkey.'_account_old']); } switch ($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 $account_new->unix_memberUid = array_merge($account_new->unix_memberUid, $_POST['users']); // remove doubles $account_new->unix_memberUid = array_flip($account_new->unix_memberUid); array_unique($account_new->unix_memberUid); $account_new->unix_memberUid = array_flip($account_new->unix_memberUid); // sort user sort($account_new->unix_memberUid); // display groupmembers page break; } if (isset($_POST['members']) && isset($_POST['remove'])) { // remove users fromlist $account_new->unix_memberUid = array_delete($_POST['members'], $account_new->unix_memberUid); break; } } while(0); $select_local = 'groupmembers'; break; case 'general': // Write all general values into $account_new if no profile should be loaded if (!$load) { $account_new->general_dn = $_POST['f_general_suffix']; $account_new->general_username = $_POST['f_general_username']; $account_new->general_uidNumber = $_POST['f_general_uidNumber']; $account_new->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]|[.]|[-]|[_])*$', $account_new->general_username)) $errors[] = array('ERROR', _('Groupname'), _('Groupname contains invalid characters. Valid characters are: a-z, 0-9 and .-_ !')); if ($account_new->general_gecos=='') { $account_new->general_gecos = $account_new->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($account_new, 'group', $account_old) && is_object($account_old)) $account_new->general_username = $account_old->general_username; while ($temp = ldapexists($account_new, 'group', $account_old)) { // get last character of username $lastchar = substr($account_new->general_username, strlen($account_new->general_username)-1, 1); // Last character is no number if ( !ereg('^([0-9])+$', $lastchar)) $account_new->general_username = $account_new->general_username . '2'; else { $i=strlen($account_new->general_username)-1; $mark = false; while (!$mark) { if (ereg('^([0-9])+$',substr($account_new->general_username, $i, strlen($account_new->general_username)-$i))) $i--; else $mark=true; } // increase last number with one $firstchars = substr($account_new->general_username, 0, $i+1); $lastchars = substr($account_new->general_username, $i+1, strlen($account_new->general_username)-$i); $account_new->general_username = $firstchars . (intval($lastchars)+1); } } if ($account_new->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 $account_new->general_uidNumber = checkid($account_new, 'group', $account_old); if (is_string($account_new->general_uidNumber)) { // true if checkid has returned an error $errors[] = array('ERROR', _('ID-Number'), $account_new->general_uidNumber); if (isset($account_old)) $account_new->general_uidNumber = $account_old->general_uidNumber; else unset($account_new->general_uidNumber); } // Check if Name-length is OK. minLength=3, maxLength=20 if ( !ereg('.{3,20}', $account_new->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]).*$', $account_new->general_username)) $errors[] = array('ERROR', _('Name'), _('Name contains invalid characters. First character must be a letter')); } break; case 'samba': $samba3domains = $ldap_intern->search_domains($config_intern->get_domainSuffix()); foreach ($samba3domains as $domain) if ($_POST['f_smb_domain'] == $domain->name) $account_new->smb_domain = $domain; $account_new->smb_displayName = $_POST['f_smb_displayName']; if ($config_intern->is_samba3()) switch ($_POST['f_smb_mapgroup']) { case '*'._('Domain Guests'): $account_new->smb_mapgroup = $account_new->smb_domain->SID . "-" . '514'; break; case '*'._('Domain Users'): $account_new->smb_mapgroup = $account_new->smb_domain->SID . "-" . '513'; break; case '*'._('Domain Admins'): $account_new->smb_mapgroup = $account_new->smb_domain->SID . "-" . '512'; break; case $account_new->general_username: $account_new->smb_mapgroup = $account_new->smb_domain->SID . "-". (2 * getgid($account_new->general_username) + $account_new->smb_domain->RIDbase +1); break; } else switch ($_POST['f_smb_mapgroup']) { case '*'._('Domain Guests'): $account_new->smb_mapgroup = '514'; break; case '*'._('Domain Users'): $account_new->smb_mapgroup = '513'; break; case '*'._('Domain Admins'): $account_new->smb_mapgroup = '512'; break; case $account_new->general_username: $account_new->smb_mapgroup = (2 * getgid($account_new->general_username) + 1001); break; } // Check if value is set if (($account_new->smb_displayName=='') && isset($account_new->general_gecos)) { $account_new->smb_displayName = $account_new->general_gecos; $errors[] = array('INFO', _('Display name'), _('Inserted gecos-field as display name.')); } break; case 'quota': // Write all general values into $account_new $i=0; while ($account_new->quota[$i][0]) { $account_new->quota[$i][2] = $_POST['f_quota_'.$i.'_2']; $account_new->quota[$i][3] = $_POST['f_quota_'.$i.'_3']; $account_new->quota[$i][6] = $_POST['f_quota_'.$i.'_6']; $account_new->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])*$', $account_new->quota[$i][2])) $errors[] = array('ERROR', _('Block soft quota'), _('Block soft quota contains invalid characters. Only natural numbers are allowed')); if (!ereg('^([0-9])*$', $account_new->quota[$i][3])) $errors[] = array('ERROR', _('Block hard quota'), _('Block hard quota contains invalid characters. Only natural numbers are allowed')); if (!ereg('^([0-9])*$', $account_new->quota[$i][6])) $errors[] = array('ERROR', _('Inode soft quota'), _('Inode soft quota contains invalid characters. Only natural numbers are allowed')); if (!ereg('^([0-9])*$', $account_new->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 $account_new if ($_POST['f_final_changegids']) $final_changegids = $_POST['f_final_changegids'] ; break; } do { // X-Or, only one if() can be true if ($_POST['next_members']) { if (!is_array($errors)) $select_local='groupmembers'; else $select_local=$select; break; } if ($_POST['next_general']) { if (!is_array($errors)) $select_local='general'; else $select_local=$select; break; } if ($_POST['next_samba']) { if (!is_array($errors)) $select_local='samba'; else $select_local=$select; break; } if ($_POST['next_quota']) { if (!is_array($errors)) $select_local='quota'; else $select_local=$select; break; } if ($_POST['next_final']) { if (!isset($errors)) $select_local='final'; else $select_local=$select; break; } if ($_POST['next_reset']) { $account_new = $account_old; $account_new->unix_password=''; $account_new->smb_password=''; $account_new->smb_flagsW = 0; $account_new->general_dn = substr($account_new->general_dn, strpos($account_new->general_dn, ',')+1); $select_local = $select; break; } if ( $_POST['create'] ) { // Create-Button was pressed if ($account_old) $result = modifygroup($account_new,$account_old); else $result = creategroup($account_new); // account.inc if ( $result==1 || $result==3 ) $select_local = 'finish'; else $select_local = 'final'; break; } // Reset variables if recreate-button was pressed if ($_POST['createagain']) { $select_local='general'; unset($account_new); $account_new = loadGroupProfile('default'); $account_new ->type = 'group'; break; } if ($_POST['backmain']) { metaRefresh("../lists/listgroups.php"); if (isset($_SESSION['account_'.$varkey.'_account_new'])) unset($_SESSION['account_'.$varkey.'_account_new']); if (isset($_SESSION['account_'.$varkey.'_account_old'])) unset($_SESSION['account_'.$varkey.'_account_old']); if (isset($_SESSION['account_'.$varkey.'_final_changegids'])) unset($_SESSION['account_'.$varkey.'_final_changegids']); die; break; } if ($load) { $account_new->general_dn = $_POST['f_general_suffix']; $account_new->general_username = $_POST['f_general_username']; $account_new->general_uidNumber = $_POST['f_general_uidNumber']; $account_new->general_gecos = $_POST['f_general_gecos']; // load profile if ($_POST['f_general_selectprofile']!='') $values = loadGroupProfile($_POST['f_general_selectprofile']); if (is_object($values)) { while (list($key, $val) = each($values)) // Set only defined values if (isset($val)) $account_new->$key = $val; } if ($config_intern->scriptServer) { // load quotas from profile and check if they are valid $values = getquotas('group', $account_old->general_username); if (isset($account_new->quota[0])) { // check quotas from profile $i=0; // check quota settings while (isset($account_new->quota[$i])) { $found = (-1); for ($j=0; $jquota); $j++) if ($values->quota[$j][0]==$account_new->quota[$i][0]) $found = $j; if ($found==-1) unset($account_new->quota[$i]); else { $account_new->quota[$i][1] = $values->quota[$found][1]; $account_new->quota[$i][5] = $values->quota[$found][5]; $account_new->quota[$i][4] = $values->quota[$found][4]; $account_new->quota[$i][8] = $values->quota[$found][8]; $i++; } } $account_new->quota = array_values($account_new->quota); } else { // No quotas saved in profile if (is_object($values)) { while (list($key, $val) = each($values)) // Set only defined values if (isset($val)) $account_new->$key = $val; } } } // select general page after group has been loaded $select_local='general'; break; } if ($_POST['save']) { // save profile saveGroupProfile($account_new, $_POST['f_finish_safeProfile']); // select last page displayed before user is created $select_local='final'; break; } if ($_POST['groupmembers']) { $select_local='groupmembers'; break; } // Set selected page to general if no page was defined. should only true if groupedit.php wasn't called by itself if (!$select_local) $select_local='general'; } while(0); // Write HTML-Header echo $header_intern; echo ""; echo _("Create new Account"); echo "\n". "\n". "\n". "\n". "\n". "
\n". "\n"; if (is_array($errors)) { echo "\n"; for ($i=0; $i"; } // print_r($account_old); 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 'groupmembers': ldapreload('user'); $temp2 = $userDN_intern; unset($temp2[0]); foreach ($temp2 as $temp) $users[] = $temp['cn']; sort($users, SORT_STRING); echo "\n"; echo "
\n\n\n
"; echo "
"; echo _('Please select page:'); echo "\n"; echo "\n
"; echo "\n
"; if ($config_intern->is_samba3()) { echo "\n
"; } echo "scriptPath)) echo " disabled "; echo "value=\""; echo _('Quota'); echo "\">\n
"; echo ""; if (isset($account_old)) { echo "

"; echo _("Reset all changes."); echo "
"; echo "\n"; } echo "
"; echo "
". _('Additional group members') . "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n\n
"; echo _('Group members'); echo ""; if (count($account_new->unix_memberUid)!=0) { echo "\n"; } echo "
"; echo " "; echo "\">

"; echo ""._('Help')."
"; echo _('Available users'); echo "\n"; if (count($users)!=0) { echo "\n"; } echo "
\n
\n
\n"; break; case 'general': // General Account Settings // load list of profiles $profilelist = getGroupProfiles(); // Show page info echo "\n"; echo "\n\n
"; echo "
"; echo _('Please select page:'); echo "\n"; echo "\n
"; echo "\n
"; if ($config_intern->is_samba3()) { echo "\n
"; } echo "scriptPath)) echo " disabled "; echo "value=\""; echo _('Quota'); echo "\">\n
"; echo ""; if (isset($account_old)) { echo "

"; echo _("Reset all changes."); echo "
"; echo "\n"; } echo "
"; echo "\n\n\n
"; echo "
"; echo _("General properties"); echo "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n". "\n\n\n\n\n\n\n
"; echo _("Groupname")."*"; echo "". "general_username."\">". ""._('Help')."
"; echo _('GID number'); echo "general_uidNumber."\">". ""._('Help'). "
"; echo _('Description'); echo "general_gecos."\">"._('Help')."
"; echo _('Suffix'); echo ""._('Help'). "
"; echo _('Values with * are required'); echo "
\n
"; if (count($profilelist)!=0) { echo "
"; echo _("Load profile"); echo "\n\n\n\n\n
"; echo "\n". ""; echo _('Help')."
\n
\n"; } echo "
\n
\n"; break; case 'samba': // Samba Settings $samba3domains = $ldap_intern->search_domains($config_intern->get_domainSuffix()); echo "\n"; echo "\n\n\n
"; echo "
"; echo _('Please select page:'); echo "\n"; echo "\n
"; echo "\n
"; echo "\n
"; echo "scriptPath)) echo " disabled "; echo "value=\""; echo _('Quota'); echo "\">\n
"; echo ""; if (isset($account_old)) { echo "

"; echo _("Reset all changes."); echo "
"; echo "\n"; } echo "
"; echo "
"._('Samba properties')."\n"; echo "\n\n\n\n\n\n\n'."\n".''."\n".''."\n"; echo "
"; echo _("Display name"); echo "". "smb_displayName."\">". ""._('Help')."
"; echo _('Windows groupname'); echo "". ''._('Help').''. '
'; echo _('Domain'); echo ''._('Help').'
\n
\n
\n"; break; case 'quota': // Quota Settings if ($config_intern->scriptServer && !isset($account_new->quota[0]) ) { // load quotas $values = getquotas('group', $account_new->general_username); if (is_object($values)) { while (list($key, $val) = each($values)) // Set only defined values if (isset($val)) $account_new->$key = $val; } if (is_object($values) && isset($account_old)) { while (list($key, $val) = each($values)) // Set only defined values if (isset($val)) $account_old->$key = $val; } } echo "\n"; echo "\n\n\n
"; echo "
"; echo _('Please select page:'); echo "\n"; echo "\n
"; echo "\n
"; if ($config_intern->is_samba3()) { echo "\n
"; } echo "\n
"; echo ""; if (isset($account_old)) { echo "

"; echo _("Reset all changes."); echo "
"; echo "\n"; } echo "
"; echo ''; echo "
"._('Quota properties')."\n"; echo "'."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n"; echo ''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n".''."\n"; $i=0; while ($account_new->quota[$i][0]) { echo ''; // used blocks echo ''; // blocks soft limit echo ''; // blocks hard limit echo ''; // block grace period echo ''; // used inodes echo ''; // inodes soft limit echo ''; // inodes hard limit echo ''; // inodes grace period $i++; } echo "
"; echo _('Mountpoint'); echo ''; echo _('Used blocks'); echo ''; echo _('Soft block limit'); echo ''; echo _('Hard block limit'); echo ''; echo _('Grace block period'); echo ''; echo _('Used inodes'); echo ''; echo _('Soft inode limit'); echo ''; echo _('Hard inode limit'); echo ''; echo _('Grace inode period'); echo '
'._('Help').''._('Help').''. ''._('Help').''._('Help').''. ''._('Help').''._('Help').''. ''._('Help').''._('Help').''. ''._('Help').'
'.$account_new->quota[$i][0].''.$account_new->quota[$i][1].''.$account_new->quota[$i][4].''.$account_new->quota[$i][5].''.$account_new->quota[$i][8].'
\n
\n
\n"; break; case 'final': // Final Settings $disabled = ""; if ($config_intern->is_samba3()) { if (!isset($account_new->smb_domain)) { // Samba page nit viewd; can not create group because if missing options $disabled = "disabled"; } } echo ''; echo "\n"; echo "\n\n
"; echo "
"; echo _('Please select page:'); echo "\n"; echo "\n
"; echo "\n
"; if ($config_intern->is_samba3()) { echo "\n
"; } echo "scriptPath)) echo " disabled "; echo "value=\""; echo _('Quota'); echo "\">\n
"; echo ""; if (isset($account_old)) { echo "

"; echo _("Reset all changes."); echo "
"; echo "\n"; } echo "
"; echo "\n\n\n
"; echo "
"; echo _("Save profile"); echo "\n\n\n\n\n
"; echo ''; echo "'._('Help'); echo "
\n
\n
\n"; echo "
"; if ($account_old) echo _('Modify'); else echo _('Create'); echo "\n"; echo ""; if (($account_old) && ($account_new->general_uidNumber != $account_old->general_uidNumber)) { echo ''; StatusMessage ('INFO', _('GID-number has changed. You have to run the following command as root in order to change existing file-permissions:'), 'find / -gid ' . $account_old->general_uidNumber . ' -exec chgrp ' . $account_new->general_uidNumber . ' {} \;'); echo ''."\n"; echo ''."\n"; } if ($disabled == "disabled") { // Samba page nit viewd; can not create group because if missing options echo ""; StatusMessage("ERROR", _("Samba Options not set!"), _("Please check settings on samba page.")); echo ""; } if (isset($account_old->general_objectClass)) { if (($config_intern->is_samba3()) && (!in_array('sambaGroupMapping', $account_old->general_objectClass))) { echo ''; StatusMessage('WARN', _('ObjectClass sambaGroupMapping not found.'), _('Have to add objectClass sambaGroupMapping.')); echo "\n"; } if (!in_array('posixGroup', $account_old->general_objectClass)) { echo ''; StatusMessage('WARN', _('ObjectClass posixGroup not found.'), _('Have to add objectClass posixGroup.')); echo "\n"; } } echo "
'; echo ''; echo _('Change GID-Number of all users in group to new value'); echo '
'."\n"; echo "
\n
\n
"; break; case 'finish': // Final Settings if (($config_intern->samba3 =='yes') && !isset($account_new->smb_mapgroup)) $disabled = 'disabled'; else $disabled = ''; echo ''; echo "
"._('Success')."\n"; echo ""; echo ''."\n".'
'; echo _('Group').' '; echo $account_new->general_username; if ($account_old) echo ' '._('has been modified').'.'; else echo ' '._('has been created').'.'; echo '
'; if (!$account_old) { echo' '; } echo ''. ''. '
'; ?>