";
echo "";
@@ -443,9 +445,7 @@ class accountContainer {
// display html-code from mdule
$function = '$result = $this->module[$this->order[$this->module[\'main\']->current_page]]->display_html_'.$this->module['main']->subpage.'($post);';
eval ($function);
- echo "\n";
$this->parse_html($this->order[$this->module['main']->current_page], $result);
- echo " \n";
// Display rest of html-page
echo "\n";
echo " \n";
@@ -457,6 +457,7 @@ class accountContainer {
function parse_html($module, $input) {
if (is_array($input)) {
+ echo "\n";
for ($i=0; $i\n";
@@ -479,8 +480,8 @@ class accountContainer {
if ($input[$i][$j]['size']!='') $output .= ' size="' . $input[$i][$j]['size'] . '"';
if ($input[$i][$j]['maxlength']!='') $output .= ' maxlength="' . $input[$i][$j]['maxlength'] . '"';
if ($input[$i][$j]['value']!='') $output .= ' value="' . $input[$i][$j]['value'] . '"';
- if (isset($input[$i][$j]['disabled'])) $output .= ' disabled';
- if (isset($input[$i][$j]['checked'])) $output .= ' checked';
+ if ($input[$i][$j]['disabled']) $output .= ' disabled';
+ if ($input[$i][$j]['checked']) $output .= ' checked';
$output .= ">\n";
echo $output;
break;
@@ -490,12 +491,12 @@ class accountContainer {
echo ">\n";
echo "\n";
break;
case 'select':
+ if (!is_array($input[$i][$j]['options'])) $input[$i][$j]['options'] = array ( $input[$i][$j]['options'] );
+ if (!is_array($input[$i][$j]['options_selected'])) $input[$i][$j]['options_selected'] = array ( $input[$i][$j]['options_selected'] );
echo "\n";
@@ -506,10 +507,12 @@ class accountContainer {
// merge both option arrays and sort them.
$options = array_merge ($input[$i][$j]['options'], $input[$i][$j]['options_selected'] );
$options = array_unique($options);
- sort($options, SORT_STRING);
+ sort($options, SORT_NUMERIC);
foreach ($options as $option) {
- if (in_array($option, $input[$i][$j]['options_selected'])) echo "\n";
- else echo "\n";
+ if ($option!='') {
+ if (in_array($option, $input[$i][$j]['options_selected'])) echo "\n";
+ else echo "\n";
+ }
}
echo " | \n";
break;
@@ -517,16 +520,14 @@ class accountContainer {
echo "\n";
- echo "\n";
$this->parse_html($module, $input[$i][$j]['value']);
- echo " \n";
echo " | \n";
break;
case 'help':
echo "\n";
- echo "" . _('Help') . " | \n";
+ echo "" . _('Help') . "\n";
break;
default:
echo "Unrecognized type: " . $input[$i][$j]['kind'] . " | \n";
@@ -536,6 +537,7 @@ class accountContainer {
echo "\n";
}
}
+ echo " \n";
}
/* Add attributes to variable. Syntax is array( attribute = array ( objectClass1 => MUST|MAX, objectClass2 => MUST|MAY ), ... )
@@ -795,6 +797,8 @@ class accountContainer {
else {
// Add module if it exists
if (class_exists($objectClass)) {
+ print $objectClass;
+ print " X";
$this->module[$objectClass] = new $objectClass($this->base);
}
else trigger_error (_("objectClass $objectClass required but no module found."), E_USER_WARNING);
@@ -853,7 +857,7 @@ class accountContainer {
* for a new account
*/
function new_account() {
- $modulelist = array('posixAccount', 'shadowAccount', 'sambaAccount');
+ $modulelist = array('posixAccount', 'sambaAccount');
// *** fixme add modules from config which should be used but not yet in loaded account
foreach ($modulelist as $objectClass) $this->add_objectClass($objectClass);
@@ -1031,6 +1035,7 @@ class accountContainer {
$temparray[0] = $singleresult[0];
$temparray[1] = _($singleresult[1]);
$temparray[2] = _($singleresult[2]);
+ $errors[] = $temparray;
}
}
}
diff --git a/lam/lib/modules/inetOrgPerson.inc b/lam/lib/modules/inetOrgPerson.inc
index 30948989..c5315c90 100644
--- a/lam/lib/modules/inetOrgPerson.inc
+++ b/lam/lib/modules/inetOrgPerson.inc
@@ -183,7 +183,7 @@ class inetOrgPerson {
if (isset($this->attributes['host'])) {
$host = $post['host'];
if ((!$host=='') && !ereg('^([a-z]|[A-Z]|[0-9]|[.]|[-])+(([,])+([ ])*([a-z]|[A-Z]|[0-9]|[.]|[-])+)*$', $host))
- $errors[] = array('ERROR', _('Unix workstations'), _('Unix workstations is invalid.'), 'host');
+ $errors['host'][] = array('ERROR', _('Unix workstations'), _('Unix workstations is invalid.'));
$hosts = explode(" ", $host);
$this->attributes['host'] = array();
foreach ($hosts as $host)
@@ -192,18 +192,18 @@ class inetOrgPerson {
// Do some regex-checks and return error if attributes are set to wrong values
if (!$profile) {
- if ( !ereg('^([a-z]|[A-Z]|[-]|[ ]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+$', $this->attributes['givenName'][0])) $errors[] = array('ERROR', _('Given name'), _('Given name contains invalid characters'), 'givenName');
- if ( !ereg('^([a-z]|[A-Z]|[-]|[ ]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+$', $this->attributes['sn'][0])) $errors[] = array('ERROR', _('Surname'), _('Surname contains invalid characters'), 'sn');
- if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/]|[-])*$', $this->attributes['telephoneNumber'][0])) $errors[] = array('ERROR', _('Telephone number'), _('Please enter a valid telephone number!'), 'telephoneNumber');
- if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/]|[-])*$', $this->attributes['mobileTelephoneNumber'][0])) $errors[] = array('ERROR', _('Mobile number'), _('Please enter a valid mobile number!'), 'mobileTelephoneNumber');
- if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/]|[-])*$', $this->attributes['facsimileTelephoneNumber'][0])) $errors[] = array('ERROR', _('Fax number'), _('Please enter a valid fax number!'), 'facsimileTelephoneNumber');
- if ( !ereg('^(([0-9]|[A-Z]|[a-z]|[.]|[-]|[_])+[@]([0-9]|[A-Z]|[a-z]|[-])+([.]([0-9]|[A-Z]|[a-z]|[-])+)*)*$', $this->attributes['mail'][0])) $errors[] = array('ERROR', _('eMail address'), _('Please enter a valid eMail address!'), 'mail');
- if ( !ereg('^([0-9]|[A-Z]|[a-z]|[-]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $this->attributes['street'][0])) $errors[] = array('ERROR', _('Street'), _('Please enter a valid street name!'), 'street');
- if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $this->attributes['postalAddress'][0])) $errors[] = array('ERROR', _('Postal address'), _('Please enter a valid postal address!'), 'postalAdress');
- if ( !ereg('^([0-9]|[A-Z]|[a-z])*$', $this->attributes['personal_postalCode'][0])) $errors[] = array('ERROR', _('Postal code'), _('Please enter a valid postal code!'), 'personal_postalCode');
+ if ( !ereg('^([a-z]|[A-Z]|[-]|[ ]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+$', $this->attributes['givenName'][0])) $errors['givenName'][] = array('ERROR', _('Given name'), _('Given name contains invalid characters'));
+ if ( !ereg('^([a-z]|[A-Z]|[-]|[ ]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+$', $this->attributes['sn'][0])) $errors['sn'][] = array('ERROR', _('Surname'), _('Surname contains invalid characters'));
+ if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/]|[-])*$', $this->attributes['telephoneNumber'][0])) $errors['telephoneNumber'][] = array('ERROR', _('Telephone number'), _('Please enter a valid telephone number!'));
+ if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/]|[-])*$', $this->attributes['mobileTelephoneNumber'][0])) $errors['mobileTelephoneNumber'][] = array('ERROR', _('Mobile number'), _('Please enter a valid mobile number!'));
+ if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/]|[-])*$', $this->attributes['facsimileTelephoneNumber'][0])) $errors['facsimileTelephoneNumber'][] = array('ERROR', _('Fax number'), _('Please enter a valid fax number!'));
+ if ( !ereg('^(([0-9]|[A-Z]|[a-z]|[.]|[-]|[_])+[@]([0-9]|[A-Z]|[a-z]|[-])+([.]([0-9]|[A-Z]|[a-z]|[-])+)*)*$', $this->attributes['mail'][0])) $errors['mail'] = array('ERROR', _('eMail address'), _('Please enter a valid eMail address!'));
+ if ( !ereg('^([0-9]|[A-Z]|[a-z]|[-]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $this->attributes['street'][0])) $errors['street'][] = array('ERROR', _('Street'), _('Please enter a valid street name!'));
+ if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $this->attributes['postalAddress'][0])) $errors['postalAdress'][] = array('ERROR', _('Postal address'), _('Please enter a valid postal address!'));
+ if ( !ereg('^([0-9]|[A-Z]|[a-z])*$', $this->attributes['personal_postalCode'][0])) $errors['personal_postalCode'][] = array('ERROR', _('Postal code'), _('Please enter a valid postal code!'));
}
- if ( !ereg('^([0-9]|[A-Z]|[a-z]|[-]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $this->attributes['title'][0])) $errors[] = array('ERROR', _('Title'), _('Please enter a valid title!'), 'title');
- if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $this->attributes['employeeType'][0])) $errors[] = array('ERROR', _('Employee type'), _('Please enter a valid employee type!'), 'employeeType');
+ if ( !ereg('^([0-9]|[A-Z]|[a-z]|[-]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $this->attributes['title'][0])) $errors['title'][] = array('ERROR', _('Title'), _('Please enter a valid title!'));
+ if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $this->attributes['employeeType'][0])) $errors['employeeType'][] = array('ERROR', _('Employee type'), _('Please enter a valid employee type!'));
// Return error-messages
if (is_array($errors)) return $errors;
return 0;
diff --git a/lam/lib/modules/main.inc b/lam/lib/modules/main.inc
index 28dbbc05..f311a6fe 100644
--- a/lam/lib/modules/main.inc
+++ b/lam/lib/modules/main.inc
@@ -141,12 +141,12 @@ class main {
}
// save profile
if ($post['saveProfile']) {
- if ($post['selectSaveProfile']=='') $errors[] = array('ERROR', _('Save profile'), _('No profilename given.'));
+ if ($post['selectSaveProfile']=='') $errors['saveProfile'][] = array('ERROR', _('Save profile'), _('No profilename given.'));
else {
$function = 'save'.ucfirst($scope).'Profile();';
eval($function);
- if ($function) $errors[] = array('INFO', _('Save profile'), _('New profile created.'));
- else $errors[] = array('ERROR', _('Save profile'), _('Wrong profilename given.'));
+ if ($function) $errors['saveProfile'][] = array('INFO', _('Save profile'), _('New profile created.'));
+ else $errors['saveProfile'][] = array('ERROR', _('Save profile'), _('Wrong profilename given.'));
}
if (is_array($errors) && !$profile) return $errors;
else return 0;
diff --git a/lam/lib/modules/posixAccount.inc b/lam/lib/modules/posixAccount.inc
index d0da3e6a..c3e9997e 100644
--- a/lam/lib/modules/posixAccount.inc
+++ b/lam/lib/modules/posixAccount.inc
@@ -155,9 +155,16 @@ class posixAccount {
return array('attributes', 'groups');
}
- function profile_attributes() {
- // array of attribtues wich are unique and not allowed to store in profile
- //array unique_attributes ( 'user' => array ('cn', 'rid', 'uid', 'uidNumber', 'userPassword') );
+ /*
+ */
+ function get_help($id) {
+ switch ($id) {
+ case "description":
+ return array ("ext" => "FALSE", "Headline" => _("Description"),
+ "Text" => _("Host Description."));
+ break;
+ }
+ return false;
}
/* This function returns all ldap attributes
@@ -253,7 +260,7 @@ class posixAccount {
// Remove primary group from additional groups
for ($i=0; $igroups); $i++) {
- if ($this->groups[$i]==$_SESSION[$_SESSION[$this->base]->cache]->getgrnam($this->attributes['gidNumber'])) unset($this->groups[$i]);
+ if ($this->groups[$i]==$_SESSION[$_SESSION[$this->base]->cache]->getgrnam($this->attributes['gidNumber'][0])) unset($this->groups[$i]);
}
// Set additional group memberships
@@ -331,15 +338,15 @@ class posixAccount {
/* Write variables into object and do some regexp checks
*/
- function proccess_attributes($post) {
+ function proccess_attributes($post, $profile=false) {
if ($this->orig['uid'][0]!='' && $post['uid']!=$this->attributes['uid'][0])
- $errors[] = array('INFO', _('UID'), _('UID has changed. Do you want to change home directory?'), 'uid');
+ $errors['uid'][] = array('INFO', _('UID'), _('UID has changed. Do you want to change home directory?'));
if ($this->orig['gidNumber'][0]!='' && $_SESSION[$_SESSION[$this->base]->cache]->getgid($post['gidNumber'])!=$this->attributes['gidNumber'][0])
- $errors[] = array('INFO', _('GID number'), sprintf(_('GID number has changed. To keep file ownership you have to run the following command as root: \'find / -gid %s -uid %s -exec chgrp %s {} \;\''), $this->orig['gidNumber'][0], $this->orig['uidNumber'][0], $_SESSION[$_SESSION[$this->base]->cache]->getgid($post['gidNumber'])), 'gidNumber');
+ $errors['gidNumber'][] = array('INFO', _('GID number'), sprintf(_('GID number has changed. To keep file ownership you have to run the following command as root: \'find / -gid %s -uid %s -exec chgrp %s {} \;\''), $this->orig['gidNumber'][0], $this->orig['uidNumber'][0], $_SESSION[$_SESSION[$this->base]->cache]->getgid($post['gidNumber'])));
if ($this->orig['uidNumber'][0]!='' && $post['uidNumber']!=$this->attributes['uidNumber'][0])
- $errors[] = array('INFO', _('UID number'), sprintf(_('UID number has changed. To keep file ownership you have to run the following command as root: \'find / -uid %s -exec chown %s {} \;\''), $this->orig['uidNumber'][0], $this->attributes['uidNumber'][0]), 'uidNumber');
+ $errors['uidNumber'][] = array('INFO', _('UID number'), sprintf(_('UID number has changed. To keep file ownership you have to run the following command as root: \'find / -uid %s -exec chown %s {} \;\''), $this->orig['uidNumber'][0], $this->attributes['uidNumber'][0]));
if (isset($post['homeDirectory']) && $this->orig['homeDirectory'][0]!='' && $post['homeDirectory']!=$this->attributes['homeDirectory'][0])
- $errors[] = array('INFO', _('Home directory'), sprintf(_('Home directory changed. To keep home directory you have to run the following command as root: \'mv %s %s\''), $this->orig['homeDirectory'][0], $this->attributes['homeDirectory'][0]), 'homeDirectory');
+ $errors['homeDirectory'][] = array('INFO', _('Home directory'), sprintf(_('Home directory changed. To keep home directory you have to run the following command as root: \'mv %s %s\''), $this->orig['homeDirectory'][0], $this->attributes['homeDirectory'][0]));
// Load attributes
$this->attributes['uid'][0] = $post['uid'];
@@ -355,150 +362,153 @@ class posixAccount {
else $this->userPassword_no=false;
if ($post['userPassword_lock']) $this->userPassword_lock=true;
else $this->userPassword_lock=false;
- if (isset($post['userPassword'])) {
- if ($post['userPassword'] != $post['userPassword2']) {
- $errors[] = array('ERROR', _('Password'), _('Please enter the same password in both password-fields.'), 'userPassword');
- unset ($post['userPassword2']);
- }
- else $this->userPassword($post['userPassword']);
- }
- if ($post['genpass']) $this->userPassword(genpasswd());
- // Check if UID is valid. If none value was entered, the next useable value will be inserted
- // load min and may uidNumber
- if ($_SESSION[$this->base]->type=='user') {
- $minID = intval($_SESSION[$_SESSION[$this->base]->config]->get_minUID());
- $maxID = intval($_SESSION[$_SESSION[$this->base]->config]->get_maxUID());
- }
- if ($_SESSION[$this->base]->type=='host') {
- $minID = intval($_SESSION[$_SESSION[$this->base]->config]->get_minMachine());
- $maxID = intval($_SESSION[$_SESSION[$this->base]->config]->get_maxMachine());
- }
- $dn_uids = $_SESSION[$_SESSION[$this->base]->cache]->get_cache('uidNumber', 'posixAccount', '*');
- // get_cache will return an array ( dn1 => array(uidnumber1), dn2 => array(uidnumber2), ... )
- foreach ($dn_uids as $uid) $uids[] = $uid[0];
- if(is_array($uids)) sort ($uids, SORT_NUMERIC);
- if ($this->attributes['uidNumber'][0]=='') {
- // No id-number given
- if ($this->orig['uidNumber'][0]=='') {
- // new account -> we have to find a free id-number
- if (count($uids)!=0) {
- // There are some uids
- // Store highest id-number
- $id = $uids[count($uids)-1];
- // Return minimum allowed id-number if all found id-numbers are too low
- if ($id < $minID) $this->attributes['uidNumber'][0] = $minID;
- // Return higesht used id-number + 1 if it's still in valid range
- if ($id < $maxID) $this->attributes['uidNumber'][0] = $id+1;
- /* If this function is still running we have to fid a free id-number between
- * the used id-numbers
- */
- $i = intval($minID);
- while (in_array($i, $uids)) $i++;
- if ($i>$maxID)
- $errors[] = array('ERROR', _('ID-Number'), _('No free ID-Number!'), 'uidNumber');
- else {
- $this->attributes['uidNumber'][0] = $i;
- $errors[] = array('WARN', _('ID-Number'), _('It is possible that this ID-number is reused. This can cause several problems because files with old permissions might still exist. To avoid this warning set maxUID to a higher value.'), 'uidNumber');
- }
+ if (!$profile) {
+ if (isset($post['userPassword'])) {
+ if ($post['userPassword'] != $post['userPassword2']) {
+ $errors['userPassword'][] = array('ERROR', _('Password'), _('Please enter the same password in both password-fields.'));
+ unset ($post['userPassword2']);
}
- else $this->attributes['uidNumber'][0] = $minID;
- // return minimum allowed id-number if no id-numbers are found
+ else $this->userPassword($post['userPassword']);
}
- else $this->attributes['uidNumber'][0] = $this->orig['uidNumber'][0];
- // old account -> return id-number which has been used
- }
- else {
- // Check manual ID
- // id-number is out of valid range
- if ( ($this->attributes['uidNumber'][0]!=$post['uidNumber']) && ($this->attributes['uidNumber'][0] < $minID || $this->attributes['uidNumber'][0] > $maxID)) $errors[] = array('ERROR', _('ID-Number'), sprintf(_('Please enter a value between %s and %s!'), $minID, $maxID), 'uidNumber');
- // $uids is allways an array but not if no entries were found
- if (is_array($uids)) {
- // id-number is in use and account is a new account
- if ((in_array($this->attributes['uidNumber'][0], $uids)) && $this->orig['uidNumber'][0]=='') $errors[] = array('ERROR', _('ID-Number'), _('ID is already in use'), 'uidNumber');
- // id-number is in use, account is existing account and id-number is not used by itself
- if ((in_array($this->attributes['uidNumber'][0], $uids)) && $this->orig['uidNumber'][0]!='' && ($this->orig['uidNumber'][0] != $this->attributes['uidNumber'][0]) ) {
- $errors[] = array('ERROR', _('ID-Number'), _('ID is already in use'), 'uidNumber');
- $this->attributes['uidNumber'][0] = $this->orig['uidNumber'][0];
+ if ($post['genpass']) $this->userPassword(genpasswd());
+ // Check if UID is valid. If none value was entered, the next useable value will be inserted
+ // load min and may uidNumber
+ if ($_SESSION[$this->base]->type=='user') {
+ $minID = intval($_SESSION[$_SESSION[$this->base]->config]->get_minUID());
+ $maxID = intval($_SESSION[$_SESSION[$this->base]->config]->get_maxUID());
+ }
+ if ($_SESSION[$this->base]->type=='host') {
+ $minID = intval($_SESSION[$_SESSION[$this->base]->config]->get_minMachine());
+ $maxID = intval($_SESSION[$_SESSION[$this->base]->config]->get_maxMachine());
+ }
+ $dn_uids = $_SESSION[$_SESSION[$this->base]->cache]->get_cache('uidNumber', 'posixAccount', '*');
+ // get_cache will return an array ( dn1 => array(uidnumber1), dn2 => array(uidnumber2), ... )
+ foreach ($dn_uids as $uid) $uids[] = $uid[0];
+ if(is_array($uids)) sort ($uids, SORT_NUMERIC);
+ if ($this->attributes['uidNumber'][0]=='') {
+ // No id-number given
+ if ($this->orig['uidNumber'][0]=='') {
+ // new account -> we have to find a free id-number
+ if (count($uids)!=0) {
+ // There are some uids
+ // Store highest id-number
+ $id = $uids[count($uids)-1];
+ // Return minimum allowed id-number if all found id-numbers are too low
+ if ($id < $minID) $this->attributes['uidNumber'][0] = $minID;
+ // Return higesht used id-number + 1 if it's still in valid range
+ if ($id < $maxID) $this->attributes['uidNumber'][0] = $id+1;
+ /* If this function is still running we have to fid a free id-number between
+ * the used id-numbers
+ */
+ $i = intval($minID);
+ while (in_array($i, $uids)) $i++;
+ if ($i>$maxID)
+ $errors['uidNumber'][] = array('ERROR', _('ID-Number'), _('No free ID-Number!'));
+ else {
+ $this->attributes['uidNumber'][0] = $i;
+ $errors['uidNumber'][] = array('WARN', _('ID-Number'), _('It is possible that this ID-number is reused. This can cause several problems because files with old permissions might still exist. To avoid this warning set maxUID to a higher value.'));
+ }
+ }
+ else $this->attributes['uidNumber'][0] = $minID;
+ // return minimum allowed id-number if no id-numbers are found
+ }
+ else $this->attributes['uidNumber'][0] = $this->orig['uidNumber'][0];
+ // old account -> return id-number which has been used
+ }
+ else {
+ // Check manual ID
+ // id-number is out of valid range
+ if ( ($this->attributes['uidNumber'][0]!=$post['uidNumber']) && ($this->attributes['uidNumber'][0] < $minID || $this->attributes['uidNumber'][0] > $maxID)) $errors['uidNumber'][] = array('ERROR', _('ID-Number'), sprintf(_('Please enter a value between %s and %s!'), $minID, $maxID));
+ // $uids is allways an array but not if no entries were found
+ if (is_array($uids)) {
+ // id-number is in use and account is a new account
+ if ((in_array($this->attributes['uidNumber'][0], $uids)) && $this->orig['uidNumber'][0]=='') $errors['uidNumber'][] = array('ERROR', _('ID-Number'), _('ID is already in use'));
+ // id-number is in use, account is existing account and id-number is not used by itself
+ if ((in_array($this->attributes['uidNumber'][0], $uids)) && $this->orig['uidNumber'][0]!='' && ($this->orig['uidNumber'][0] != $this->attributes['uidNumber'][0]) ) {
+ $errors['uidNumber'][] = array('ERROR', _('ID-Number'), _('ID is already in use'));
+ $this->attributes['uidNumber'][0] = $this->orig['uidNumber'][0];
+ }
}
}
}
-
if ($_SESSION[$this->base]->type=='user') {
- if (($this->attributes['uid'][0] != $post['uid']) && ereg('[A-Z]$', $post['uid']))
- $errors[] = array('WARN', _('Username'), _('You are using a capital letters. This can cause problems because windows isn\'t case-sensitive.'), 'uid');
+ if (($this->attributes['uid'][0] != $post['uid']) && ereg('[A-Z]$', $post['uid']) && !$profile)
+ $errors['uid'][] = array('WARN', _('Username'), _('You are using a capital letters. This can cause problems because windows isn\'t case-sensitive.'));
// Check if Homedir is valid
- $this->attributes['homeDirectory'][0] = str_replace('$group', $_SESSION[$_SESSION[$this->base]->cache]->getgrnam($this->attributes['gidNumber'][0]), $this->attributes['homeDirectory'][0]);
- if ($this->attributes['uid'][0] != '')
- $this->attributes['homeDirectory'][0] = str_replace('$user', $this->attributes['uid'][0], $this->attributes['homeDirectory'][0]);
- if ($this->attributes['homeDirectory'][0] != $post['homeDirectory']) $errors[] = array('INFO', _('Home directory'), _('Replaced $user or $group in homedir.'));
+ if (!$profile) {
+ $this->attributes['homeDirectory'][0] = str_replace('$group', $_SESSION[$_SESSION[$this->base]->cache]->getgrnam($this->attributes['gidNumber'][0]), $this->attributes['homeDirectory'][0]);
+ if ($this->attributes['uid'][0] != '')
+ $this->attributes['homeDirectory'][0] = str_replace('$user', $this->attributes['uid'][0], $this->attributes['homeDirectory'][0]);
+ if ($this->attributes['homeDirectory'][0] != $post['homeDirectory']) $errors['homeDirecotry'][] = array('INFO', _('Home directory'), _('Replaced $user or $group in homedir.'));
+ }
if ( !ereg('^[/]([a-z]|[A-Z])([a-z]|[A-Z]|[0-9]|[.]|[-]|[_])*([/]([a-z]|[A-Z])([a-z]|[A-Z]|[0-9]|[.]|[-]|[_])*)*$', $this->attributes['homeDirectory'][0] ))
- $errors[] = array('ERROR', _('Home directory'), _('Homedirectory contains invalid characters.'), 'homeDirectory');
+ $errors['homeDirecotry'][] = array('ERROR', _('Home directory'), _('Homedirectory contains invalid characters.'), 'homeDirectory');
// Check if Username contains only valid characters
- if ( !ereg('^([a-z]|[A-Z]|[0-9]|[.]|[-]|[_])+$', $this->attributes['uid'][0]))
- $errors[] = array('ERROR', _('Username'), _('Username contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and .-_ !'), 'uid');
+ if ( !ereg('^([a-z]|[A-Z]|[0-9]|[.]|[-]|[_])+$', $this->attributes['uid'][0]) && !$profile)
+ $errors['uid'][] = array('ERROR', _('Username'), _('Username contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and .-_ !'));
}
- if ($_SESSION[$this->base]->type=='host') {
+ if ($_SESSION[$this->base]->type=='host' && !$profile) {
if (($this->attributes['uid'][0] != $post['form_account_uid']) && ereg('[A-Z]$', $post['form_account_uid']))
- $errors[] = array('WARN', _('Hostname'), _('You are using a capital letters. This can cause problems because windows isn\'t case-sensitive.'), 'uid');
+ $errors['uid'][] = array('WARN', _('Hostname'), _('You are using a capital letters. This can cause problems because windows isn\'t case-sensitive.'));
// Check if Username contains only valid characters
if ( !ereg('^([a-z]|[A-Z]|[0-9]|[.]|[-]|[_])+[$]$', $this->attributes['uid'][0]))
- $errors[] = array('ERROR', _('Hostname'), _('Hostname contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and .-_ ! Hostname must end with $ !'), 'uid');
+ $errors['uid'][] = array('ERROR', _('Hostname'), _('Hostname contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and .-_ ! Hostname must end with $ !'));
}
// Create automatic useraccount with number if original user already exists
// Reset name to original name if new name is in use
// Set username back to original name if new username is in use
- if ($_SESSION[$_SESSION[$this->base]->cache]->in_cache($this->attributes['uid'][0],'uid', '*')!=false && ($this->orig['uid'][0]!='')) {
- $this->attributes['uid'][0] = $this->orig['uid'][0];
- }
- // Change uid to a new uid until a free uid is found
- else while ($_SESSION[$_SESSION[$this->base]->cache]->in_cache($this->attributes['uid'][0], 'uid', '*')) {
- if ($_SESSION[$this->base]->type=='host') $this->attributes['uid'][0] = substr($this->attributes['uid'][0], 0, -1);
- // get last character of username
- $lastchar = substr($this->attributes['uid'][0], strlen($this->attributes['uid'][0])-1, 1);
- // Last character is no number
- if ( !ereg('^([0-9])+$', $lastchar))
- /* Last character is no number. Therefore we only have to
- * add "2" to it.
- */
- if ($_SESSION[$this->base]->type=='host') $this->attributes['uid'][0] = $this->attributes['uid'][0] . '2$';
- else $this->attributes['uid'][0] = $this->attributes['uid'][0] . '2';
- else {
- /* Last character is a number -> we have to increase the number until we've
- * found a groupname with trailing number which is not in use.
- *
- * $i will show us were we have to split groupname so we get a part
- * with the groupname and a part with the trailing number
- */
- $i=strlen($this->attributes['uid'][0])-1;
- $mark = false;
- // Set $i to the last character which is a number in $account_new->general_username
- while (!$mark) {
- if (ereg('^([0-9])+$',substr($this->attributes['uid'][0], $i, strlen($this->attributes['uid'][0])-$i))) $i--;
- else $mark=true;
- }
- // increase last number with one
- $firstchars = substr($this->attributes['uid'][0], 0, $i+1);
- $lastchars = substr($this->attributes['uid'][0], $i+1, strlen($this->attributes['uid'][0])-$i);
- // Put username together
- if ($_SESSION[$this->base]->type=='host') $this->attributes['uid'][0] = $firstchars . (intval($lastchars)+1)."$";
- else $this->attributes['uid'][0] = $firstchars . (intval($lastchars)+1);
+ if (!$profile) {
+ if ($_SESSION[$_SESSION[$this->base]->cache]->in_cache($this->attributes['uid'][0],'uid', '*')!=false && ($this->orig['uid'][0]!='')) {
+ $this->attributes['uid'][0] = $this->orig['uid'][0];
+ }
+ // Change uid to a new uid until a free uid is found
+ else while ($_SESSION[$_SESSION[$this->base]->cache]->in_cache($this->attributes['uid'][0], 'uid', '*')) {
+ if ($_SESSION[$this->base]->type=='host') $this->attributes['uid'][0] = substr($this->attributes['uid'][0], 0, -1);
+ // get last character of username
+ $lastchar = substr($this->attributes['uid'][0], strlen($this->attributes['uid'][0])-1, 1);
+ // Last character is no number
+ if ( !ereg('^([0-9])+$', $lastchar))
+ /* Last character is no number. Therefore we only have to
+ * add "2" to it.
+ */
+ if ($_SESSION[$this->base]->type=='host') $this->attributes['uid'][0] = $this->attributes['uid'][0] . '2$';
+ else $this->attributes['uid'][0] = $this->attributes['uid'][0] . '2';
+ else {
+ /* Last character is a number -> we have to increase the number until we've
+ * found a groupname with trailing number which is not in use.
+ *
+ * $i will show us were we have to split groupname so we get a part
+ * with the groupname and a part with the trailing number
+ */
+ $i=strlen($this->attributes['uid'][0])-1;
+ $mark = false;
+ // Set $i to the last character which is a number in $account_new->general_username
+ while (!$mark) {
+ if (ereg('^([0-9])+$',substr($this->attributes['uid'][0], $i, strlen($this->attributes['uid'][0])-$i))) $i--;
+ else $mark=true;
+ }
+ // increase last number with one
+ $firstchars = substr($this->attributes['uid'][0], 0, $i+1);
+ $lastchars = substr($this->attributes['uid'][0], $i+1, strlen($this->attributes['uid'][0])-$i);
+ // Put username together
+ if ($_SESSION[$this->base]->type=='host') $this->attributes['uid'][0] = $firstchars . (intval($lastchars)+1)."$";
+ else $this->attributes['uid'][0] = $firstchars . (intval($lastchars)+1);
+ }
}
- }
-
// Show warning if lam has changed username
if ($_SESSION[$this->base]->type=='user')
if ($this->attributes['uid'][0] != $post['uid']) {
- $errors[] = array('WARN', _('Username'), _('Username in use. Selected next free username.'), 'uid');
+ $errors['uid'][] = array('WARN', _('Username'), _('Username in use. Selected next free username.'));
}
if ($_SESSION[$this->base]->type=='host')
if ($this->attributes['uid'][0] != $post['uid']) {
- $errors[] = array('WARN', _('Hostname'), _('Hostname in use. Selected next free hostname.'), 'uid');
+ $errors['uid'][] = array('WARN', _('Hostname'), _('Hostname in use. Selected next free hostname.'));
}
-
- if (!ereg('^([a-z]|[A-Z]|[0-9]|[\|]|[\#]|[\*]|[\,]|[\.]|[\;]|[\:]|[\_]|[\-]|[\+]|[\!]|[\%]|[\&]|[\/]|[\?]|[\{]|[\[]|[\(]|[\)]|[\]]|[\}])*$', $this->userPassword()))
- $errors[] = array('ERROR', _('Password'), _('Password contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and #*,.;:_-+!$%&/|?{[()]}= !'), 'userPassword');
+ if (!ereg('^([a-z]|[A-Z]|[0-9]|[\|]|[\#]|[\*]|[\,]|[\.]|[\;]|[\:]|[\_]|[\-]|[\+]|[\!]|[\%]|[\&]|[\/]|[\?]|[\{]|[\[]|[\(]|[\)]|[\]]|[\}])*$', $this->userPassword()))
+ $errors['userPassword'][] = array('ERROR', _('Password'), _('Password contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and #*,.;:_-+!$%&/|?{[()]}= !'));
+ }
// Return error-messages
if (is_array($errors)) return $errors;
// Go to additional group page when no error did ocour and button was pressed
@@ -508,7 +518,7 @@ class posixAccount {
/* Write variables into object and do some regexp checks
*/
- function proccess_group($post) {
+ function proccess_group($post, $profile=false) {
do { // X-Or, only one if() can be true
if (isset($post['addgroups']) && isset($post['addgroups_button'])) { // Add groups to list
// Add new group
@@ -534,10 +544,10 @@ class posixAccount {
function display_html_attributes($post, $profile=false) {
$groups = $_SESSION[$_SESSION[$this->base]->cache]->findgroups(); // list of all groupnames
$shelllist = getshells(); // list of all valid shells
- if ($this->attributes['userPassword'][0] != $this->orig['userPassword'][0]) $password=$this->userPassword();
- else $password='';
if (!$profile) {
+ if ($this->attributes['userPassword'][0] != $this->orig['userPassword'][0]) $password=$this->userPassword();
+ else $password='';
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _("Username").'*' ),
1 => array ( 'kind' => 'input', 'name' => 'uid', 'type' => 'text', 'size' => '20', 'maxlength' => '20', 'value' => $this->attributes['uid'][0]),
2 => array ('kind' => 'help', 'value' => 'uid'));
@@ -554,9 +564,11 @@ class posixAccount {
2 => array ('kind' => 'help', 'value' => 'gidNumber'));
if ($_SESSION[$this->base]->type=='user') {
- $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Additional groups') ),
- 1 => array ( 'kind' => 'input', 'name' => 'addgroup', 'type' => 'submit', 'value' => _('Edit groups')),
- 2 => array ('kind' => 'help', 'value' => 'addgroup'));
+ if (!$profile) {
+ $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Additional groups') ),
+ 1 => array ( 'kind' => 'input', 'name' => 'addgroup', 'type' => 'submit', 'value' => _('Edit groups')),
+ 2 => array ('kind' => 'help', 'value' => 'addgroup'));
+ }
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Home directory').'*' ),
1 => array ( 'kind' => 'input', 'name' => 'homeDirectory', 'type' => 'text', 'size' => '30', 'maxlength' => '255', 'value' => $this->attributes['homeDirectory'][0]),
2 => array ('kind' => 'help', 'value' => 'homeDirectory'));
diff --git a/lam/lib/modules/posixGroup.inc b/lam/lib/modules/posixGroup.inc
index c0056f52..337a8c5c 100644
--- a/lam/lib/modules/posixGroup.inc
+++ b/lam/lib/modules/posixGroup.inc
@@ -143,6 +143,18 @@ class posixGroup {
return array('attributes', 'user');
}
+ /*
+ */
+ function get_help($id) {
+ switch ($id) {
+ case "description":
+ return array ("ext" => "FALSE", "Headline" => _("Description"),
+ "Text" => _("Host Description."));
+ break;
+ }
+ return false;
+ }
+
/* This function returns all ldap attributes
* which are part of posixGroup and returns
* also their values.
@@ -295,9 +307,9 @@ class posixGroup {
/* Write variables into object and do some regexp checks
*/
- function proccess_attributes($post) {
+ function proccess_attributes($post, $profile=false) {
if ($this->orig['gidNumber'][0]!='' && $post['gidNumber']!=$this->attributes['gidNumber'][0])
- $errors[] = array('INFO', _('GID number'), _('GID number has changed. Please select checkbox to change GID number of users and hosts.'), 'gidNumber');
+ $errors['gidNumber'][] = array('INFO', _('GID number'), _('GID number has changed. Please select checkbox to change GID number of users and hosts.'));
// Load attributes
$this->attributes['cn'][0] = $post['cn'];
@@ -307,123 +319,126 @@ class posixGroup {
else $this->userPassword_no=false;
if ($post['userPassword_lock']) $this->userPassword_lock=true;
else $this->userPassword_lock=false;
- if ($post['changegids']) $this->changegids=true;
- else $this->changegids=false;
+ If (!$profile) {
+ if ($post['changegids']) $this->changegids=true;
+ else $this->changegids=false;
- if (isset($post['userPassword'])) {
- if ($post['userPassword'] != $post['userPassword2']) {
- $errors[] = array('ERROR', _('Password'), _('Please enter the same password in both password-fields.'), 'userPassword');
- unset ($post['userPassword2']);
+ if (isset($post['userPassword'])) {
+ if ($post['userPassword'] != $post['userPassword2']) {
+ $errors['userPassword'][] = array('ERROR', _('Password'), _('Please enter the same password in both password-fields.'));
+ unset ($post['userPassword2']);
+ }
+ else $this->userPassword($post['userPassword']);
}
- else $this->userPassword($post['userPassword']);
- }
- if ($post['genpass']) $this->userPassword(genpasswd());
+ if ($post['genpass']) $this->userPassword(genpasswd());
- // Check if UID is valid. If none value was entered, the next useable value will be inserted
- // load min and may uidNumber
- $minID = intval($_SESSION[$_SESSION[$this->base]->config]->get_minGID());
- $maxID = intval($_SESSION[$_SESSION[$this->base]->config]->get_maxGID());
- $dn_gids = $_SESSION[$_SESSION[$this->base]->cache]->get_cache('gidNumber', 'posixGroup', '*');
- // get_cache will return an array ( dn1 => array(uidnumber1), dn2 => array(uidnumber2), ... )
- foreach ($dn_gids as $gid) $gids[] = $gid[0];
- if(is_array($gids)) sort ($gids, SORT_NUMERIC);
- if ($this->attributes['gidNumber'][0]=='') {
- // No id-number given
- if ($this->orig['gidNumber'][0]=='') {
- // new account -> we have to find a free id-number
- if (count($gids)!=0) {
- // There are some uids
- // Store highest id-number
- $id = $gids[count($gids)-1];
- // Return minimum allowed id-number if all found id-numbers are too low
- if ($id < $minID) $this->attributes['gidNumber'][0] = $minID;
- // Return higesht used id-number + 1 if it's still in valid range
- if ($id < $maxID) $this->attributes['gidNumber'][0] = $id+1;
- /* If this function is still running we have to fid a free id-number between
- * the used id-numbers
+ // Check if UID is valid. If none value was entered, the next useable value will be inserted
+ // load min and may uidNumber
+ $minID = intval($_SESSION[$_SESSION[$this->base]->config]->get_minGID());
+ $maxID = intval($_SESSION[$_SESSION[$this->base]->config]->get_maxGID());
+ $dn_gids = $_SESSION[$_SESSION[$this->base]->cache]->get_cache('gidNumber', 'posixGroup', '*');
+ // get_cache will return an array ( dn1 => array(uidnumber1), dn2 => array(uidnumber2), ... )
+ foreach ($dn_gids as $gid) $gids[] = $gid[0];
+ if(is_array($gids)) sort ($gids, SORT_NUMERIC);
+ if ($this->attributes['gidNumber'][0]=='') {
+ // No id-number given
+ if ($this->orig['gidNumber'][0]=='') {
+ // new account -> we have to find a free id-number
+ if (count($gids)!=0) {
+ // There are some uids
+ // Store highest id-number
+ $id = $gids[count($gids)-1];
+ // Return minimum allowed id-number if all found id-numbers are too low
+ if ($id < $minID) $this->attributes['gidNumber'][0] = $minID;
+ // Return higesht used id-number + 1 if it's still in valid range
+ if ($id < $maxID) $this->attributes['gidNumber'][0] = $id+1;
+ /* If this function is still running we have to fid a free id-number between
+ * the used id-numbers
+ */
+ $i = intval($minID);
+ while (in_array($i, $gids)) $i++;
+ if ($i>$maxID)
+ $errors['gidNumber'][] = array('ERROR', _('ID-Number'), _('No free ID-Number!'));
+ else {
+ $this->attributes['gidNumber'][0] = $i;
+ $errors['gidNumber'][] = array('WARN', _('ID-Number'), _('It is possible that this ID-number is reused. This can cause several problems because files with old permissions might still exist. To avoid this warning set maxUID to a higher value.'));
+ }
+ }
+ else $this->attributes['gidNumber'][0] = $minID;
+ // return minimum allowed id-number if no id-numbers are found
+ }
+ else $this->attributes['gidNumber'][0] = $this->orig['gidNumber'][0];
+ // old account -> return id-number which has been used
+ }
+ else {
+ // Check manual ID
+ // id-number is out of valid range
+ if ( ($this->attributes['gidNumber'][0]!=$post['gidNumber']) && ($this->attributes['gidNumber'][0] < $minID || $this->attributes['gidNumber'][0] > $maxID)) $errors['gidNumber'][] = array('ERROR', _('ID-Number'), sprintf(_('Please enter a value between %s and %s!'), $minID, $maxID));
+ // $uids is allways an array but not if no entries were found
+ if (is_array($gids)) {
+ // id-number is in use and account is a new account
+ if ((in_array($this->attributes['gidNumber'][0], $gids)) && $this->orig['gidNumber'][0]=='') $errors['gidNumber'][] = array('ERROR', _('ID-Number'), _('ID is already in use'));
+ // id-number is in use, account is existing account and id-number is not used by itself
+ if ((in_array($this->attributes['gidNumber'][0], $gids)) && $this->orig['gidNumber'][0]!='' && ($this->orig['gidNumber'][0] != $this->attributes['gidNumber'][0]) ) {
+ $errors['gidNumber'][] = array('ERROR', _('ID-Number'), _('ID is already in use'));
+ $this->attributes['gidNumber'][0] = $this->orig['gidNumber'][0];
+ }
+ }
+ }
+
+ if (($this->attributes['cn'][0] != $post['cn']) && ereg('[A-Z]$', $post['cn']))
+ $errors['cn'][] = array('WARN', _('Groupname'), _('You are using a capital letters. This can cause problems because windows isn\'t case-sensitive.'));
+ // Check if Username contains only valid characters
+ if ( !ereg('^([a-z]|[A-Z]|[0-9]|[.]|[-]|[_])+$', $this->attributes['cn'][0]))
+ $errors['cn'][] = array('ERROR', _('Groupname'), _('Groupname contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and .-_ !'));
+
+ // Create automatic useraccount with number if original user already exists
+ // Reset name to original name if new name is in use
+ // Set username back to original name if new username is in use
+ if ($_SESSION[$_SESSION[$this->base]->cache]->in_cache($this->attributes['cn'][0],'cn', '*')!=false && ($this->orig['cn'][0]!='')) {
+ $this->attributes['cn'][0] = $this->orig['cn'][0];
+ }
+ // Change uid to a new uid until a free uid is found
+ else while ($_SESSION[$_SESSION[$this->base]->cache]->in_cache($this->attributes['cn'][0], 'cn', '*')) {
+ // get last character of username
+ $lastchar = substr($this->attributes['cn'][0], strlen($this->attributes['cn'][0])-1, 1);
+ // Last character is no number
+ if ( !ereg('^([0-9])+$', $lastchar))
+ /* Last character is no number. Therefore we only have to
+ * add "2" to it.
*/
- $i = intval($minID);
- while (in_array($i, $gids)) $i++;
- if ($i>$maxID)
- $errors[] = array('ERROR', _('ID-Number'), _('No free ID-Number!'), 'gidNumber');
- else {
- $this->attributes['gidNumber'][0] = $i;
- $errors[] = array('WARN', _('ID-Number'), _('It is possible that this ID-number is reused. This can cause several problems because files with old permissions might still exist. To avoid this warning set maxUID to a higher value.'), 'gidNumber');
- }
- }
- else $this->attributes['gidNumber'][0] = $minID;
- // return minimum allowed id-number if no id-numbers are found
- }
- else $this->attributes['gidNumber'][0] = $this->orig['gidNumber'][0];
- // old account -> return id-number which has been used
- }
- else {
- // Check manual ID
- // id-number is out of valid range
- if ( ($this->attributes['gidNumber'][0]!=$post['gidNumber']) && ($this->attributes['gidNumber'][0] < $minID || $this->attributes['gidNumber'][0] > $maxID)) $errors[] = array('ERROR', _('ID-Number'), sprintf(_('Please enter a value between %s and %s!'), $minID, $maxID), 'gidNumber');
- // $uids is allways an array but not if no entries were found
- if (is_array($gids)) {
- // id-number is in use and account is a new account
- if ((in_array($this->attributes['gidNumber'][0], $gids)) && $this->orig['gidNumber'][0]=='') $errors[] = array('ERROR', _('ID-Number'), _('ID is already in use'), 'gidNumber');
- // id-number is in use, account is existing account and id-number is not used by itself
- if ((in_array($this->attributes['gidNumber'][0], $gids)) && $this->orig['gidNumber'][0]!='' && ($this->orig['gidNumber'][0] != $this->attributes['gidNumber'][0]) ) {
- $errors[] = array('ERROR', _('ID-Number'), _('ID is already in use'), 'gidNumber');
- $this->attributes['gidNumber'][0] = $this->orig['gidNumber'][0];
+ $this->attributes['cn'][0] = $this->attributes['cn'][0] . '2';
+ else {
+ /* Last character is a number -> we have to increase the number until we've
+ * found a groupname with trailing number which is not in use.
+ *
+ * $i will show us were we have to split groupname so we get a part
+ * with the groupname and a part with the trailing number
+ */
+ $i=strlen($this->attributes['cn'][0])-1;
+ $mark = false;
+ // Set $i to the last character which is a number in $account_new->general_username
+ while (!$mark) {
+ if (ereg('^([0-9])+$',substr($this->attributes['cn'][0], $i, strlen($this->attributes['cn'][0])-$i))) $i--;
+ else $mark=true;
+ }
+ // increase last number with one
+ $firstchars = substr($this->attributes['cn'][0], 0, $i+1);
+ $lastchars = substr($this->attributes['cn'][0], $i+1, strlen($this->attributes['cn'][0])-$i);
+ // Put username together
+ $this->attributes['cn'][0] = $firstchars . (intval($lastchars)+1);
}
}
- }
- if (($this->attributes['cn'][0] != $post['cn']) && ereg('[A-Z]$', $post['cn']))
- $errors[] = array('WARN', _('Groupname'), _('You are using a capital letters. This can cause problems because windows isn\'t case-sensitive.'), 'cn');
- // Check if Username contains only valid characters
- if ( !ereg('^([a-z]|[A-Z]|[0-9]|[.]|[-]|[_])+$', $this->attributes['cn'][0]))
- $errors[] = array('ERROR', _('Groupname'), _('Groupname contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and .-_ !'), 'cn');
-
- // Create automatic useraccount with number if original user already exists
- // Reset name to original name if new name is in use
- // Set username back to original name if new username is in use
- if ($_SESSION[$_SESSION[$this->base]->cache]->in_cache($this->attributes['cn'][0],'cn', '*')!=false && ($this->orig['cn'][0]!='')) {
- $this->attributes['cn'][0] = $this->orig['cn'][0];
- }
- // Change uid to a new uid until a free uid is found
- else while ($_SESSION[$_SESSION[$this->base]->cache]->in_cache($this->attributes['cn'][0], 'cn', '*')) {
- // get last character of username
- $lastchar = substr($this->attributes['cn'][0], strlen($this->attributes['cn'][0])-1, 1);
- // Last character is no number
- if ( !ereg('^([0-9])+$', $lastchar))
- /* Last character is no number. Therefore we only have to
- * add "2" to it.
- */
- $this->attributes['cn'][0] = $this->attributes['cn'][0] . '2';
- else {
- /* Last character is a number -> we have to increase the number until we've
- * found a groupname with trailing number which is not in use.
- *
- * $i will show us were we have to split groupname so we get a part
- * with the groupname and a part with the trailing number
- */
- $i=strlen($this->attributes['cn'][0])-1;
- $mark = false;
- // Set $i to the last character which is a number in $account_new->general_username
- while (!$mark) {
- if (ereg('^([0-9])+$',substr($this->attributes['cn'][0], $i, strlen($this->attributes['cn'][0])-$i))) $i--;
- else $mark=true;
- }
- // increase last number with one
- $firstchars = substr($this->attributes['cn'][0], 0, $i+1);
- $lastchars = substr($this->attributes['cn'][0], $i+1, strlen($this->attributes['cn'][0])-$i);
- // Put username together
- $this->attributes['cn'][0] = $firstchars . (intval($lastchars)+1);
+ // Show warning if lam has changed username
+ if ($this->attributes['cn'][0] != $post['cn']) {
+ $errors['cn'][] = array('WARN', _('Groupname'), _('Groupname in use. Selected next free groupname.'));
}
+
+ if (!ereg('^([a-z]|[A-Z]|[0-9]|[\|]|[\#]|[\*]|[\,]|[\.]|[\;]|[\:]|[\_]|[\-]|[\+]|[\!]|[\%]|[\&]|[\/]|[\?]|[\{]|[\[]|[\(]|[\)]|[\]]|[\}])*$', $this->userPassword()))
+ $errors['userPassword'][] = array('ERROR', _('Password'), _('Password contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and #*,.;:_-+!$%&/|?{[()]}= !'));
}
- // Show warning if lam has changed username
- if ($this->attributes['cn'][0] != $post['cn']) {
- $errors[] = array('WARN', _('Groupname'), _('Groupname in use. Selected next free groupname.'), 'cn');
- }
-
- if (!ereg('^([a-z]|[A-Z]|[0-9]|[\|]|[\#]|[\*]|[\,]|[\.]|[\;]|[\:]|[\_]|[\-]|[\+]|[\!]|[\%]|[\&]|[\/]|[\?]|[\{]|[\[]|[\(]|[\)]|[\]]|[\}])*$', $this->userPassword()))
- $errors[] = array('ERROR', _('Password'), _('Password contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and #*,.;:_-+!$%&/|?{[()]}= !'), 'userPassword');
// Return error-messages
if (is_array($errors)) return $errors;
// Go to additional group page when no error did ocour and button was pressed
@@ -433,7 +448,7 @@ class posixGroup {
/* Write variables into object and do some regexp checks
*/
- function proccess_user($post) {
+ function proccess_user($post, $profile=false) {
do { // X-Or, only one if() can be true
if (isset($post['addusers']) && isset($post['addusers_button'])) { // Add groups to list
// Add new user
@@ -463,65 +478,41 @@ class posixGroup {
function display_html_attributes($post) {
if ($this->attributes['userPassword'][0] != $this->orig['userPassword'][0]) $password=$this->userPassword();
else $password='';
- echo "\n";
- echo "\n";
- echo '' . _('Groupname') . "* | \n";
- echo "attributes['cn'][0]."\"> | \n";
- echo "" . _('Help') . " | \n";
- echo " \n";
- echo "\n";
- echo "" . _('GID number') ." | \n";
- echo "attributes['gidNumber'][0]."\"> | \n";
- echo "" . _('Help') . " | \n";
- echo " \n";
- echo "\n";
- echo "" . _('Description') . " | \n";
- echo "attributes['description'][0]."\"> | \n";
- echo "" . _('Help') . " | \n";
- echo " \n";
- echo "\n";
- echo "" . _('Group members') . " | \n";
- echo " | \n";
- echo "" . _('Help') . " | \n";
- echo " \n";
- echo "\n";
- echo "" . _('Password') . " | \n";
- echo " | \n";
- echo " | \n";
- echo " \n";
- echo "\n";
- echo "" . _('Repeat password') . " | \n";
- echo " | \n";
- echo " | \n";
- echo " \n";
- echo "\n";
- echo "" . _('Use no password') . " | \n";
- echo "userPassword_no) echo " checked ";
- echo "> | \n";
- echo "" . _('Help') . " | \n";
- echo " \n";
- echo "\n";
- echo "" . _('Lock password') . " | \n";
- echo "userPassword_lock) echo " checked ";
- echo "> | \n";
- echo "" . _('Help') . " | \n";
- echo " \n";
- if ($this->attributes['gidNumber'][0]!=$this->orig['gidNumber'][0] && $this->orig['gidNumber'][0]!='') {
- echo "\n";
- echo "" . _('Change GID number of users and hosts') . " | \n";
- echo "changegids) echo " checked ";
- echo "> | \n";
- echo "" . _('Help-XX') . " | \n";
- echo " \n";
+ if (!$profile) {
+ $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _("Groupname").'*' ),
+ 1 => array ( 'kind' => 'input', 'name' => 'cn', 'type' => 'text', 'size' => '20', 'maxlength' => '20', 'value' => $this->attributes['cn'][0]),
+ 2 => array ('kind' => 'help', 'value' => 'cn'));
+ $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('GID number').'*' ),
+ 1 => array ( 'kind' => 'input', 'name' => 'gidNumber', 'type' => 'text', 'size' => '6', 'maxlength' => '6', 'value' => $this->attributes['gidNumber'][0]),
+ 2 => array ('kind' => 'help', 'value' => 'gidNumber'));
}
- echo " \n";
- return 0;
+ $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Description') ),
+ 1 => array ( 'kind' => 'input', 'name' => 'description', 'type' => 'text', 'size' => '30', 'maxlength' => '255', 'value' => $this->attributes['description'][0]),
+ 2 => array ('kind' => 'help', 'value' => 'description'));
+ if (!$profile) {
+ $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _("Group members").'*' ),
+ 1 => array ( 'kind' => 'input', 'name' => 'adduser', 'type' => 'submit', 'value' => _('Edit groups')),
+ 2 => array ('kind' => 'help', 'value' => 'adduser'));
+ $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Password') ),
+ 1 => array ( 'kind' => 'input', 'name' => 'userPassword', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => $password),
+ 2 => array ( 'kind' => 'input', 'name' => 'genpass', 'type' => 'submit', 'value' => _('Generate password')));
+ if ($post['userPassword2']!='') $password2 = $post['userPassword2'];
+ $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Repeat password') ),
+ 1 => array ( 'kind' => 'input', 'name' => 'userPassword2', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => $password2),
+ 2 => array ('kind' => 'help', 'value' => 'userPassword'));
+ }
+ $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Use no password') ),
+ 1 => array ( 'kind' => 'input', 'name' => 'userPassword_no', 'type' => 'checkbox', 'checked' => $this->userPassword_no),
+ 2 => array ('kind' => 'help', 'value' => 'userPassword_no'));
+ $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Lock password') ),
+ 1 => array ( 'kind' => 'input', 'name' => 'userPassword_lock', 'type' => 'checkbox', 'checked' => $this->userPassword_lock),
+ 2 => array ('kind' => 'help', 'value' => 'userPassword_lock'));
+ if ($this->attributes['gidNumber'][0]!=$this->orig['gidNumber'][0] && $this->orig['gidNumber'][0]!='' && !$profile) {
+ $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Change GID number of users and hosts') ),
+ 1 => array ( 'kind' => 'input', 'name' => 'changegids', 'type' => 'checkbox', 'checked' => $this->changegids),
+ 2 => array ('kind' => 'help', 'value' => 'changegids'));
+ }
+ return $return;
}
function display_html_delete($post) {
@@ -529,7 +520,7 @@ class posixGroup {
return 0;
}
- function display_html_user($post) {
+ function display_html_user($post, $profile=false) {
// load list with all groups
$dn_users = $_SESSION[$_SESSION[$this->base]->cache]->get_cache('uid', 'posixAccount', 'user');
foreach ($dn_users as $user) $users[] = $user[0];
@@ -553,42 +544,20 @@ class posixGroup {
// sort users
sort($users);
- echo "\n";
- return 0;
+ $return[] = array ( 0 => array ( 'kind' => 'fieldset', 'legend' => _("Group members"), 'value' =>
+ array ( 0 => array ( 0 => array ('kind' => 'fieldset', 'td' => array ('valign' => 'top'), 'legend' => _("Selected userss"), 'value' =>
+ array ( 0 => array ( 0 => array ( 'kind' => 'select', 'name' => 'removeusers[]', 'size' => '15', 'multiple', 'options' => $this->attributes['memberUid'])))),
+ 1 => array ( 'kind' => 'table', 'value' => array ( 0 => array ( 0 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'addusers_button',
+ 'value' => '<=')), 1 => array ( 0 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'removeusers_button', 'value' => '=>' )),
+ 2 => array ( 0 => array ( 'kind' => 'help', 'value' => 'adduser' )))),
+ 2 => array ('kind' => 'fieldset', 'td' => array ('valign' => 'top'), 'legend' => _("Available users"), 'value' =>
+ array ( 0 => array ( 0 => array ( 'kind' => 'select', 'name' => 'addusers[]', 'size' => '15', 'multiple', 'options' => $users))))
+ ))));
+
+ $return[] = array ( 0 => array ( 'kind' => 'input', 'type' => 'submit', 'value' => _('Back') ),
+ 1 => array ( 'kind' => 'text'),
+ 2 => array ('kind' => 'text'));
+ return $return;
}
}
diff --git a/lam/lib/modules/quota.inc b/lam/lib/modules/quota.inc
index b07d28ea..2149b1b3 100644
--- a/lam/lib/modules/quota.inc
+++ b/lam/lib/modules/quota.inc
@@ -95,6 +95,18 @@ class quota {
return array('attributes');
}
+ /*
+ */
+ function get_help($id) {
+ switch ($id) {
+ case "description":
+ return array ("ext" => "FALSE", "Headline" => _("Description"),
+ "Text" => _("Host Description."));
+ break;
+ }
+ return false;
+ }
+
/* This function returns all ldap attributes
* which are part of quota and returns
* also their values.
@@ -185,7 +197,7 @@ class quota {
/* Write variables into object and do some regexp checks
*/
- function proccess_attributes($post) {
+ function proccess_attributes($post, $profile=false) {
// Write all general values into $account_new
$i=0;
// loop for every mointpoint with quotas
@@ -196,17 +208,17 @@ class quota {
$this->quota[$i][7] = $post[$i . '_7'];
// Check if values are OK and set automatic values. if not error-variable will be set
if (!ereg('^([0-9])*$', $this->quota[$i][2]))
- $errors[] = array('ERROR', _('Block soft quota'), _('Block soft quota contains invalid characters. Only natural numbers are allowed'));
+ $errors[$this->quota[$i][2]][] = array('ERROR', _('Block soft quota'), _('Block soft quota contains invalid characters. Only natural numbers are allowed'));
if (!ereg('^([0-9])*$', $this->quota[$i][3]))
- $errors[] = array('ERROR', _('Block hard quota'), _('Block hard quota contains invalid characters. Only natural numbers are allowed'));
+ $errors[$this->quota[$i][3]][] = array('ERROR', _('Block hard quota'), _('Block hard quota contains invalid characters. Only natural numbers are allowed'));
if (!ereg('^([0-9])*$', $this->quota[$i][6]))
- $errors[] = array('ERROR', _('Inode soft quota'), _('Inode soft quota contains invalid characters. Only natural numbers are allowed'));
+ $errors[$this->quota[$i][6]][] = array('ERROR', _('Inode soft quota'), _('Inode soft quota contains invalid characters. Only natural numbers are allowed'));
if (!ereg('^([0-9])*$', $this->quota[$i][7]))
- $errors[] = array('ERROR', _('Inode hard quota'), _('Inode hard quota contains invalid characters. Only natural numbers are allowed'));
+ $errors[$this->quota[$i][7]][] = array('ERROR', _('Inode hard quota'), _('Inode hard quota contains invalid characters. Only natural numbers are allowed'));
if (intval($this->quota[$i][2]) > intval($this->quota[$i][3]))
- $errors[] = array('ERROR', _('Block quota'), _('Block soft quota must be smaller than block hard quota'));
+ $errors[$this->quota[$i][2]][] = array('ERROR', _('Block quota'), _('Block soft quota must be smaller than block hard quota'));
if (intval($this->quota[$i][6]) > intval($this->quota[$i][7]))
- $errors[] = array('ERROR', _('Inode quota'), _('Inode soft quota must be smaller than inode hard quota'));
+ $errors[$this->quota[$i][6]][] = array('ERROR', _('Inode quota'), _('Inode soft quota must be smaller than inode hard quota'));
$i++;
}
@@ -220,49 +232,43 @@ class quota {
* to show a page with all attributes.
* It will output a complete html-table
*/
- function display_html_attributes($post) {
- echo "\n";
- echo "\n";
- echo "" . _('Mountpoint') . " | \n";
- echo "" . _('Used blocks') . " | \n";
- echo "" . _('Soft block limit') . " | \n";
- echo "" . _('Hard block limit') . " | \n";
- echo "" . _('Grace block period') . " | \n";
- echo "" . _('Used inodes') . " | \n";
- echo "" . _('Soft inode limit') . " | \n";
- echo "" . _('Hard inode limit') . " | \n";
- echo "" . _('Grace inode period') . " | \n";
- echo " \n";
- echo "\n";
- echo "" . _('Help') . " | \n";
- echo "" . _('Help') . " | \n";
- echo "" . _('Help') . " | \n";
- echo "" . _('Help') . " | \n";
- echo "" . _('Help') . " | \n";
- echo "" . _('Help') . " | \n";
- echo "" . _('Help') . " | \n";
- echo "" . _('Help') . " | \n";
- echo "" . _('Help') . " | \n";
- echo " \n";
+ function display_html_attributes($post, $profile=false) {
+
+ $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Mountpoint') ),
+ 1 => array ( 'kind' => 'text', 'text' => _('Used blocks') ),
+ 2 => array ( 'kind' => 'text', 'text' => _('Soft block limit') ),
+ 3 => array ( 'kind' => 'text', 'text' => _('Hard block limit') ),
+ 4 => array ( 'kind' => 'text', 'text' => _('Grace block period') ),
+ 5 => array ( 'kind' => 'text', 'text' => _('Used inodes') ),
+ 6 => array ( 'kind' => 'text', 'text' => _('Soft inode limit') ),
+ 7 => array ( 'kind' => 'text', 'text' => _('Hard inode limit') ),
+ 8 => array ( 'kind' => 'text', 'text' => _('Grace inode period') ));
+
+ $return[] = array ( 0 => array ( 'kind' => 'help', 'value' => 'Mountpoint' ),
+ 1 => array ( 'kind' => 'help', 'value' => 'UsedBlocks' ),
+ 2 => array ( 'kind' => 'help', 'value' => 'SoftBlockLimit' ),
+ 3 => array ( 'kind' => 'help', 'value' => 'HardBlockLimit' ),
+ 4 => array ( 'kind' => 'help', 'value' => 'GraceBlockPeriod' ),
+ 5 => array ( 'kind' => 'help', 'value' => 'UsedInodes' ),
+ 6 => array ( 'kind' => 'help', 'value' => 'SoftInodeLimit' ),
+ 7 => array ( 'kind' => 'help', 'value' => 'HardInodeLimit' ),
+ 8 => array ( 'kind' => 'help', 'value' => 'GraceInodePeriod' ));
$i=0;
// loop for every mointpoint with enabled quotas
while ($this->quota[$i][0]) {
- echo "\n";
- echo "" . $this->quota[$i][0] . " | \n";
- echo "" . $this->quota[$i][1] . " | \n"; // used blocks
- echo "quota[$i][2] . "\"> | \n"; // blocks soft limit
- echo "quota[$i][3] . "\"> | \n"; // blocks hard limit
- echo "" . $this->quota[$i][4] . " | \n"; // block grace period
- echo "" . $this->quota[$i][5] . " | \n"; // used inodes
- echo "quota[$i][6] . "\"> | \n"; // inodes soft limit
- echo "quota[$i][7] . "\"> | \n"; // inodes hard limit
- echo "" . $this->quota[$i][8] . " | \n";
- echo " \n"; // inodes grace period
+ $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => $this->quota[$i][0] ),
+ 1 => array ( 'kind' => 'text', 'text' => $this->quota[$i][1] ),
+ 2 => array ( 'kind' => 'input', 'name' => $i . '_2', 'type' => 'text', 'size' => '12', 'maxlength' => '20', 'value' => $this->quota[$i][2]),
+ 3 => array ( 'kind' => 'input', 'name' => $i . '_3', 'type' => 'text', 'size' => '12', 'maxlength' => '20', 'value' => $this->quota[$i][3]),
+ 4 => array ( 'kind' => 'text', 'text' => $this->quota[$i][4] ),
+ 5 => array ( 'kind' => 'text', 'text' => $this->quota[$i][5] ),
+ 6 => array ( 'kind' => 'input', 'name' => $i . '_6', 'type' => 'text', 'size' => '12', 'maxlength' => '20', 'value' => $this->quota[$i][6]),
+ 7 => array ( 'kind' => 'input', 'name' => $i . '_7', 'type' => 'text', 'size' => '12', 'maxlength' => '20', 'value' => $this->quota[$i][7]),
+ 8 => array ( 'kind' => 'text', 'text' => $this->quota[$i][8] ));
$i++;
}
- echo " \n";
- return 0;
+ return $return;
}
function display_html_delete($post) {
diff --git a/lam/lib/modules/sambaAccount.inc b/lam/lib/modules/sambaAccount.inc
index 94a7fecb..71188ee6 100644
--- a/lam/lib/modules/sambaAccount.inc
+++ b/lam/lib/modules/sambaAccount.inc
@@ -150,6 +150,18 @@ class sambaAccount {
return array('attributes', 'userWorkstations');
}
+ /*
+ */
+ function get_help($id) {
+ switch ($id) {
+ case "description":
+ return array ("ext" => "FALSE", "Headline" => _("Description"),
+ "Text" => _("Host Description."));
+ break;
+ }
+ return false;
+ }
+
/* This function returns all ldap attributes
* which are part of sambaAccount and returns
* also their values.
@@ -237,7 +249,7 @@ class sambaAccount {
/* Write variables into object and do some regexp checks
*/
- function proccess_attributes($post) {
+ function proccess_attributes($post, $profile=false) {
$this->attributes['domain'][0] = $post['domain'];
// Start character
$flag = "[";
@@ -254,7 +266,7 @@ class sambaAccount {
$flag = $flag. "]";
$this->attributes['acctFlags'][0] = $flag;
- if ($_SESSION[$this->base]->type=='host') {
+ if ($_SESSION[$this->base]->type=='host' && !$profile) {
$this->attributes['primaryGroupID'][0] = $this->rids[_('Domain Computers')];
if ($post['ResetSambaPassword']) {
// *** fixme. What is the default password?
@@ -273,61 +285,79 @@ class sambaAccount {
$this->attributes['homeDrive'][0] = $post['homeDrive'];
$this->attributes['scriptPath'][0] = stripslashes($post['scriptPath']);
$this->attributes['profilePath'][0] = stripslashes($post['profilePath']);
- $rids = array_keys($this->rids);
- $wrid = false;
- for ($i=0; $iattributes['primaryGroupID'][0] = $this->rids[$rids[$i]];
+ if (!$profile) {
+ $rids = array_keys($this->rids);
+ $wrid = false;
+ for ($i=0; $iattributes['primaryGroupID'][0] = $this->rids[$rids[$i]];
+ }
}
- }
- if (!$wrid) $this->attributes['primaryGroupID'][0] = ($_SESSION[$this->base]->module['posixAccount']->attributes['gidNumber'][0]*2)+1001;
+ if (!$wrid) $this->attributes['primaryGroupID'][0] = ($_SESSION[$this->base]->module['posixAccount']->attributes['gidNumber'][0]*2)+1001;
- if (isset($post['lmPassword'])) {
- if ($post['lmPassword'] != $post['lmPassword2']) {
- $errors[] = array('ERROR', _('Password'), _('Please enter the same password in both password-fields.'), 'lmPassword');
- unset ($post['lmPassword2']);
+ if (isset($post['lmPassword'])) {
+ if ($post['lmPassword'] != $post['lmPassword2']) {
+ $errors['lmPassword'][] = array('ERROR', _('Password'), _('Please enter the same password in both password-fields.'));
+ unset ($post['lmPassword2']);
+ }
+ else $this->lmPassword($post['lmPassword']);
}
- else $this->lmPassword($post['lmPassword']);
+ if ($post['rid']== _('Administrator')) {
+ $this->attributes['rid'][0] = "500";
+ // Do a check if an administrator already exists
+ if ($_SESSION[$_SESSION[$this->base]->cache]->in_cache("500", 'rid', 'user')!=$_SESSION[$this->base]->dn_orig)
+ $errors['rid'][] = array('ERROR', _('Special user'), _('There can be only one administrator per domain.'));
+ }
+ if ($post['rid']== _('Guest')) {
+ $this->attributes['rid'][0] = "501";
+ // Do a check if an administrator already exists
+ if ($_SESSION[$_SESSION[$this->base]->cache]->in_cache("501", 'rid', 'user')!=$_SESSION[$this->base]->dn_orig)
+ $errors['rid'][] = array('ERROR', _('Special user'), _('There can be only one guest per domain.'));
+ }
+ $this->attributes['smbHome'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['smbHome'][0]);
+ $this->attributes['smbHome'][0] = str_replace('$group', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['gid'][0], $this->attributes['smbHome'][0]);
+ if ($this->attributes['smbHome'][0] != stripslashes($post['smbHome'])) $errors['smbHome'][] = array('INFO', _('Home path'), _('Inserted user- or groupname in HomePath.'));
+ $this->attributes['scriptPath'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['scriptPath'][0]);
+ $this->attributes['scriptPath'][0] = str_replace('$group', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['gid'][0], $this->attributes['scriptPath'][0]);
+ if ($this->attributes['scriptPath'][0] != stripslashes($post['scriptPath'])) $errors['scriptPath'][] = array('INFO', _('Script path'), _('Inserted user- or groupname in scriptpath.'));
+ $this->attributes['profilePath'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['profilePath'][0]);
+ $this->attributes['profilePath'][0] = str_replace('$group', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['gid'][0], $this->attributes['profilePath'][0]);
+ if ($this->attributes['profiletPath'][0] != stripslashes($post['profilePath'])) $errors['profilePath'][] = array('INFO', _('Profile path'), _('Inserted user- or groupname in profilepath.'));
+ if ( !ereg('^([a-z]|[A-Z]|[0-9]|[\|]|[\#]|[\*]|[\,]|[\.]|[\;]|[\:]|[\_]|[\-]|[\+]|[\!]|[\%]|[\&]|[\/]|[\?]|[\{]|[\[]|[\(]|[\)]|[\]]|[\}])*$',
+ $this->lmPassword())) $errors['lmPassword'][] = array('ERROR', _('Password'), _('Password contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and #*,.;:_-+!$%&/|?{[()]}= !'));
+ if ( (!$this->attributes['smbHome'][0]=='') && (!ereg('^[\][\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+([\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+)+$', $this->attributes['smbHome'][0])))
+ $errors['smbHome'][] = array('ERROR', _('Home path'), _('Home path is invalid.'));
+ if ( (!$this->attributes['scriptPath'][0]=='') && (!ereg('^([/])*([a-z]|[0-9]|[.]|[-]|[_]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+([a-z]|[0-9]|[.]|[-]|[_]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])*'.
+ '([/]([a-z]|[0-9]|[.]|[-]|[_]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+([a-z]|[0-9]|[.]|[-]|[_]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])*)*(([.][b][a][t])|([.][c][m][d]))$', $this->attributes['scriptPath'][0])))
+ $errors['scriptPath'][] = array('ERROR', _('Script path'), _('Script path is invalid!'));
+ if ( (!$this->attributes['profilePath'][0]=='') && (!ereg('^[/][a-z]([a-z]|[0-9]|[.]|[-]|[_]|[%])*([/][a-z]([a-z]|[0-9]|[.]|[-]|[_]|[%])*)*$', $this->attributes['profilePath'][0]))
+ && (!ereg('^[\][\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+([\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+)+$', $this->attributes['profilePath'][0])))
+ $errors['profilePath'][] = array('ERROR', _('Profile path'), _('Profile path is invalid!'));
}
+ else {
+ $smbHome = str_replace('$user', 'user', $this->attributes['smbHome'][0]);
+ $smbHome = str_replace('$group', 'group', $smbHome);
+ $scriptPath = str_replace('$user', 'user', $this->attributes['scriptPath'][0]);
+ $scriptPath = str_replace('$group', 'group', $scriptPath);
+ $profilePath = str_replace('$user', 'user', $this->attributes['profilePath'][0]);
+ $profilePath = str_replace('$group', 'group', $profilePath);
+ if ( (!$smbHome=='') && (!ereg('^[\][\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+([\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+)+$', $smbHome)))
+ $errors['smbHome'][] = array('ERROR', _('Home path'), _('Home path is invalid.'));
+ if ( (!$scriptPath=='') && (!ereg('^([/])*([a-z]|[0-9]|[.]|[-]|[_]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+([a-z]|[0-9]|[.]|[-]|[_]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])*'.
+ '([/]([a-z]|[0-9]|[.]|[-]|[_]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+([a-z]|[0-9]|[.]|[-]|[_]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])*)*(([.][b][a][t])|([.][c][m][d]))$', $scriptPath)))
+ $errors['scriptPath'][] = array('ERROR', _('Script path'), _('Script path is invalid!'));
+ if ( (!$profilePath=='') && (!ereg('^[/][a-z]([a-z]|[0-9]|[.]|[-]|[_]|[%])*([/][a-z]([a-z]|[0-9]|[.]|[-]|[_]|[%])*)*$', $profilePath))
+ && (!ereg('^[\][\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+([\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+)+$', $profilePath)))
+ $errors['profilePath'][] = array('ERROR', _('Profile path'), _('Profile path is invalid!'));
+ }
+
if ($post['useunixpwd']) $this->useunixpwd = true;
else $this->useunixpwd = false;
-
- if ($post['rid']== _('Administrator')) {
- $this->attributes['rid'][0] = "500";
- // Do a check if an administrator already exists
- if ($_SESSION[$_SESSION[$this->base]->cache]->in_cache("500", 'rid', 'user')!=$_SESSION[$this->base]->dn_orig)
- $errors[] = array('ERROR', _('Special user'), _('There can be only one administrator per domain.'), 'rid');
- }
- if ($post['rid']== _('Guest')) {
- $this->attributes['rid'][0] = "501";
- // Do a check if an administrator already exists
- if ($_SESSION[$_SESSION[$this->base]->cache]->in_cache("501", 'rid', 'user')!=$_SESSION[$this->base]->dn_orig)
- $errors[] = array('ERROR', _('Special user'), _('There can be only one guest per domain.'), 'rid');
- }
- $this->attributes['smbHome'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['smbHome'][0]);
- $this->attributes['smbHome'][0] = str_replace('$group', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['gid'][0], $this->attributes['smbHome'][0]);
- if ($this->attributes['smbHome'][0] != stripslashes($post['smbHome'])) $errors[] = array('INFO', _('Home path'), _('Inserted user- or groupname in HomePath.'), 'smbHome');
- $this->attributes['scriptPath'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['scriptPath'][0]);
- $this->attributes['scriptPath'][0] = str_replace('$group', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['gid'][0], $this->attributes['scriptPath'][0]);
- if ($this->attributes['scriptPath'][0] != stripslashes($post['scriptPath'])) $errors[] = array('INFO', _('Script path'), _('Inserted user- or groupname in scriptpath.'), 'scriptPath');
- $this->attributes['profilePath'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['profilePath'][0]);
- $this->attributes['profilePath'][0] = str_replace('$group', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['gid'][0], $this->attributes['profilePath'][0]);
- if ($this->attributes['profiletPath'][0] != stripslashes($post['profilePath'])) $errors[] = array('INFO', _('Profile path'), _('Inserted user- or groupname in profilepath.'), 'profilePath');
- if ( (!$this->attributes['smbHome'][0]=='') && (!ereg('^[\][\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+([\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+)+$', $this->attributes['smbHome'][0])))
- $errors[] = array('ERROR', _('Home path'), _('Home path is invalid.'), 'smbHome');
- if ( !ereg('^([a-z]|[A-Z]|[0-9]|[\|]|[\#]|[\*]|[\,]|[\.]|[\;]|[\:]|[\_]|[\-]|[\+]|[\!]|[\%]|[\&]|[\/]|[\?]|[\{]|[\[]|[\(]|[\)]|[\]]|[\}])*$',
- $this->lmPassword())) $errors[] = array('ERROR', _('Password'), _('Password contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and #*,.;:_-+!$%&/|?{[()]}= !'), 'lmPassword');
- if ( (!$this->attributes['scriptPath'][0]=='') && (!ereg('^([/])*([a-z]|[0-9]|[.]|[-]|[_]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+([a-z]|[0-9]|[.]|[-]|[_]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])*'.
- '([/]([a-z]|[0-9]|[.]|[-]|[_]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+([a-z]|[0-9]|[.]|[-]|[_]|[%]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])*)*(([.][b][a][t])|([.][c][m][d]))$', $this->attributes['scriptPath'][0])))
- $errors[] = array('ERROR', _('Script path'), _('Script path is invalid!'), 'scriptPath');
- if ( (!$this->attributes['profilePath'][0]=='') && (!ereg('^[/][a-z]([a-z]|[0-9]|[.]|[-]|[_]|[%])*([/][a-z]([a-z]|[0-9]|[.]|[-]|[_]|[%])*)*$', $this->attributes['profilePath'][0]))
- && (!ereg('^[\][\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+([\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+)+$', $this->attributes['profilePath'][0])))
- $errors[] = array('ERROR', _('Profile path'), _('Profile path is invalid!'), 'profilePath');
}
if ((!$this->attributes['domain'][0]=='') && !ereg('^([a-z]|[A-Z]|[0-9]|[-])+$', $this->attributes['domain'][0]))
- $errors[] = array('ERROR', _('Domain name'), _('Domain name contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and -.'), 'domain');
+ $errors['domain'][] = array('ERROR', _('Domain name'), _('Domain name contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and -.'));
if (is_array($errors)) return $errors;
if ($post['userWorkstations']) return 'userWorkstations';
@@ -336,48 +366,50 @@ class sambaAccount {
/* Write variables into object and do some regexp checks
*/
- function proccess_userWorkstations($post) {
+ function proccess_userWorkstations($post, $profile=false) {
// Load attributes
- do { // X-Or, only one if() can be true
- if (isset($post['availableUserWorkstations']) && isset($post['userWorkstations_add'])) { // Add workstations to list
- $temp = str_replace(' ', '', $this->attributes['userWorkstations'][0]);
- $workstations = explode (',', $temp);
- for ($i=0; $iattributes['userWorkstations'][0] = $workstations[0];
- for ($i=1; $iattributes['userWorkstations'][0] = $this->attributes['userWorkstations'][0] . "," . $workstations[$i];
+ if ($_SESSION[$this->base]->type=='user') {
+ do { // X-Or, only one if() can be true
+ if (isset($post['availableUserWorkstations']) && isset($post['userWorkstations_add'])) { // Add workstations to list
+ $temp = str_replace(' ', '', $this->attributes['userWorkstations'][0]);
+ $workstations = explode (',', $temp);
+ for ($i=0; $iattributes['userWorkstations'][0] = $workstations[0];
+ for ($i=1; $iattributes['userWorkstations'][0] = $this->attributes['userWorkstations'][0] . "," . $workstations[$i];
+ }
+ break;
}
- break;
- }
- if (isset($post['userWorkstations']) && isset($post['userWorkstations_remove'])) { // remove // Add workstations from list
- // Put all workstations in array
- $temp = str_replace(' ', '', $this->attributes['userWorkstations'][0]);
- $workstations = explode (',', $temp);
- for ($i=0; $iattributes['userWorkstations'][0] = $workstations[0];
- for ($i=1; $iattributes['userWorkstations'][0] = $this->attributes['userWorkstations'][0] . "," . $workstations[$i];
+ if (isset($post['userWorkstations']) && isset($post['userWorkstations_remove'])) { // remove // Add workstations from list
+ // Put all workstations in array
+ $temp = str_replace(' ', '', $this->attributes['userWorkstations'][0]);
+ $workstations = explode (',', $temp);
+ for ($i=0; $iattributes['userWorkstations'][0] = $workstations[0];
+ for ($i=1; $iattributes['userWorkstations'][0] = $this->attributes['userWorkstations'][0] . "," . $workstations[$i];
+ }
+ break;
}
- break;
- }
- } while(0);
- if ($post['attributes']) return 'attributes';
+ } while(0);
+ if ($post['attributes']) return 'attributes';
+ }
return 0;
}
@@ -385,189 +417,136 @@ class sambaAccount {
* to show a page with all attributes.
* It will output a complete html-table
*/
- function display_html_attributes($post) {
+ function display_html_attributes($post, $profile=false) {
if ($_SESSION[$this->base]->type=='user') {
$canchangedate = getdate($this->attributes['pwdCanChange'][0]);
$mustchangedate = getdate($this->attributes['pwdMustChange'][0]);
- echo ''.
- ''.
- ''.
- ''.
- ''.
- ''.
- '';
- echo "\n\n";
- echo " \n";
- echo "" . _('Samba password') . " | \n";
- echo "lmPassword() . "\"> | \n";
- echo " \n";
- echo "\n";
- echo "" . _('Repeat password') . " | \n";
- echo "lmPassword();
- echo "\"> | \n";
- echo " | \n";
- echo " \n";
- if ($_SESSION[$this->base]->module['posixAccount']->orig['userPassword'][0] != $_SESSION[$this->base]->module['posixAccount']->attributes['userPassword'][0]) {
- echo "\n";
- echo "" . _('Use unix password') . " | \n";
- echo "useunixpwd) echo " checked ";
- echo "> | \n";
- echo "" . _('Help') . " | ";
- echo " \n";
+ $return[] = array ( 0 => array ( 'kind' => 'input', 'name' => 'pwdCanChange_h', 'type' => 'hidden', 'value' => $canchangedate['hours']),
+ 1 => array ( 'kind' => 'input', 'name' => 'pwdCanChange_m', 'type' => 'hidden', 'value' => $canchangedate['minutes']),
+ 2 => array ( 'kind' => 'input', 'name' => 'pwdCanChange_s', 'type' => 'hidden', 'value' => $canchangedate['seconds']),
+ 3 => array ( 'kind' => 'input', 'name' => 'pwdMustChange_h', 'type' => 'hidden', 'value' => $mustchangedate['hours']),
+ 4 => array ( 'kind' => 'input', 'name' => 'pwdMustChange_m', 'type' => 'hidden', 'value' => $mustchangedate['minutes']),
+ 5 => array ( 'kind' => 'input', 'name' => 'pwdMustChange_s', 'type' => 'hidden', 'value' => $mustchangedate['seconds']),
+ 6 => array ( 'kind' => 'input', 'name' => 'acctFlagsU', 'type' => 'hidden', 'value' => 'true'));
+
+ if (!$profile) {
+ if ($this->attributes['lmPassword'][0] != $this->orig['lmPassword'][0]) $password=$this->lmPassword();
+ else $password='';
+ $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Samba password') ),
+ 1 => array ( 'kind' => 'input', 'name' => 'lmPassword', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => $password));
+ if ($post['lmPassword2']!='') $password2 = $post['lmPassword2'];
+ $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Repeat password') ),
+ 1 => array ( 'kind' => 'input', 'name' => 'lmPassword2', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => $password2),
+ 2 => array ('kind' => 'help', 'value' => 'lmPassword'));
}
- echo "\n";
- echo "" . _('Use no password') . " | \n";
- echo "attributes['acctFlags'][0], "N")) echo " checked ";
- echo "> | \n";
- echo "" . _('Help' ) ." | \n";
- echo " \n";
- echo "\n";
- echo "" . _('Password does not expire') . " | \n";
- echo "attributes['acctFlags'][0], "X")) echo " checked ";
- echo "> | \n";
- echo "" . _('Help') . " | \n";
- echo " \n";
- echo "\n";
- echo "" . _('User can change password') . " | \n";
- echo " | \n";
- echo "" . _('Help') . " | \n";
- echo " \n";
- echo "\n";
- echo "" . _('User must change password') . " | \n";
- echo " | \n";
- echo "" . _('Help') . " | \n";
- echo " \n";
- echo "\n";
- echo "" . _('Account is deactivated') . " | \n";
- echo "attributes['acctFlags'][0], "D")) echo " checked ";
- echo "> | \n";
- echo "" . _('Help') . " | \n";
- echo " \n";
- echo "\n";
- echo "" . _('Home drive') . " | \n";
- echo " | \n";
- echo "" . _('Help') . " | \n";
- echo " \n";
- echo "\n";
- echo "" . _('Home path') . " | \n";
- echo "attributes['smbHome'][0] . "\"> | \n";
- echo "" . _('Help') . " | \n";
- echo " \n";
- echo "\n";
- echo "" . _('Profile path') . " | \n";
- echo "attributes['profilePath'][0] . "\"> | \n";
- echo "" . _('Help') . " | \n";
- echo " \n";
- echo "\n";
- echo "" . _('Script path') . " | \n";
- echo "attributes['scriptPath'][0] . "\"> | \n";
- echo "" . _('Help') . " | \n";
- echo " \n";
- echo "\n";
- echo "" . _('Samba workstations') . " | \n";
- echo " | \n";
- echo "" . _('Help') . " | \n";
- echo " \n";
- echo "\n";
- echo "" . _('Windows group') . " | \n";
- echo " | \n";
- echo "" . _('Help') . " | \n";
- echo " \n";
- echo "\n";
- echo "" . _('Special user') . " | \n";
- echo " | \n";
- echo "" . _('Help-XX') . " | \n";
- echo " \n";
- echo "\n";
- echo "" . _('Domain') . " | \n";
- echo "attributes['domain'][0] . "\"> | \n";
- echo "" . _('Help') . " | \n";
- echo " \n";
- echo " \n";
+ else $options[] = _('Guest');
+ if ($wrid) $options[] = _('Ordinary user');
+ else $selected[] = _('Ordinary user');
+ $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Special user') ),
+ 1 => array ( 'kind' => 'select', 'name' => 'rid', 'options' => $options, 'options_selected' => $selected),
+ 2 => array ( 'kind' => 'help', 'value' => 'rid' ));
+ }
+ $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Domain') ),
+ 1 => array ( 'kind' => 'input', 'type' => 'text', 'name' => 'domain', 'size' => '20', 'maxlength' => '255', 'value' => $this->attributes['domain'][0]),
+ 2 => array ( 'kind' => 'help', 'value' => 'domain' ));
}
+
if ($_SESSION[$this->base]->type=='host') {
- echo '';
- echo "\n";
+ $return[] = array ( 0 => array ( 'kind' => 'input', 'name' => 'acctFlagsW', 'type' => 'hidden', 'value' => 'true' ));
+ if (!$profile) {
+ $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Reset password') ),
+ 1 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'ResetSambaPassword'),
+ 2 => array ( 'kind' => 'help', 'value' => 'ResetSambaPassword' ));
+ }
+ $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Domain') ),
+ 1 => array ( 'kind' => 'input', 'type' => 'text', 'name' => 'domain', 'size' => '20', 'maxlength' => '255', 'value' => $this->attributes['domain'][0]),
+ 2 => array ( 'kind' => 'help', 'value' => 'domain' ));
}
- return 0;
+
+ return $return;
}
function display_html_delete($post) {
@@ -579,51 +558,33 @@ class sambaAccount {
* It will output a complete html-table
*/
function display_html_userWorkstations($post) {
- // Get list of all hosts.
- $result = $_SESSION[$_SESSION[$this->base]->cache]->get_cache('uid', 'sambaAccount', 'host');
- if (is_array($result)) {
- foreach ($result as $host) $availableUserWorkstations[] = str_replace("$", '', $host[0]);
- sort($availableUserWorkstations, SORT_STRING);
- $result = str_replace(' ', '', $this->attributes['userWorkstations'][0]);
- $userWorkstations = explode (',', $result);
- $availableUserWorkstations = array_delete($userWorkstations, $availableUserWorkstations);
+ if ($_SESSION[$this->base]->type=='user') {
+ // Get list of all hosts.
+ $result = $_SESSION[$_SESSION[$this->base]->cache]->get_cache('uid', 'sambaAccount', 'host');
+ if (is_array($result)) {
+ foreach ($result as $host) $availableUserWorkstations[] = str_replace("$", '', $host[0]);
+ sort($availableUserWorkstations, SORT_STRING);
+ $result = str_replace(' ', '', $this->attributes['userWorkstations'][0]);
+ $userWorkstations = explode (',', $result);
+ $availableUserWorkstations = array_delete($userWorkstations, $availableUserWorkstations);
+ }
+
+ $return[] = array ( 0 => array ( 'kind' => 'fieldset', 'legend' => _("Allowed workstations"), 'value' =>
+ array ( 0 => array ( 0 => array ('kind' => 'fieldset', 'td' => array ('valign' => 'top'), 'legend' => _("Allowed workstations"), 'value' =>
+ array ( 0 => array ( 0 => array ( 'kind' => 'select', 'name' => 'userWorkstations[]', 'size' => '15', 'multiple', 'options' => $userWorkstations)))),
+ 1 => array ( 'kind' => 'table', 'value' => array ( 0 => array ( 0 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'userWorkstations_add',
+ 'value' => '<=')), 1 => array ( 0 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'userWorkstations_remove', 'value' => '=>' )),
+ 2 => array ( 0 => array ( 'kind' => 'help', 'value' => 'userWorkstations' )))),
+ 2 => array ('kind' => 'fieldset', 'td' => array ('valign' => 'top'), 'legend' => _("Available workstations"), 'value' =>
+ array ( 0 => array ( 0 => array ( 'kind' => 'select', 'name' => 'availableUserWorkstations[]', 'size' => '15', 'multiple', 'options' => $availableUserWorkstations))))
+ ))));
+
+ $return[] = array ( 0 => array ( 'kind' => 'input', 'type' => 'submit', 'value' => _('Back') ),
+ 1 => array ( 'kind' => 'text'),
+ 2 => array ('kind' => 'text'));
}
- echo "\n";
+
+ return $return;
}
}
diff --git a/lam/lib/modules/sambaGroupMapping.inc b/lam/lib/modules/sambaGroupMapping.inc
index 3f0a730c..9d48f514 100644
--- a/lam/lib/modules/sambaGroupMapping.inc
+++ b/lam/lib/modules/sambaGroupMapping.inc
@@ -118,6 +118,18 @@ class sambaGroupMapping {
return array('attributes');
}
+ /*
+ */
+ function get_help($id) {
+ switch ($id) {
+ case "description":
+ return array ("ext" => "FALSE", "Headline" => _("Description"),
+ "Text" => _("Host Description."));
+ break;
+ }
+ return false;
+ }
+
/* This function returns all ldap attributes
* which are part of sambaGroupMapping and returns
* also their values.
@@ -187,32 +199,39 @@ class sambaGroupMapping {
/* Write variables into object and do some regexp checks
*/
- function proccess_attributes($post) {
- // Get Domain SID from name
- $sambaDomains = $_SESSION[$_SESSION[$this->base]->ldap]->search_domains($_SESSION[$_SESSION[$this->base]->config]->get_domainSuffix());
- for ($i=0; $iname) {
- $SID = $sambaDomains[$i]->SID;
- $RIDbase = $sambaDomain[$i]->RIDbase;
- }
-
+ function proccess_attributes($post, $profile=false) {
// Load attributes
$this->attributes['displayName'][0] = $post['displayName'];
$this->attributes['sambaGroupType'][0] = 2;
- $rids = array_keys($this->rids);
- $wrid = false;
- for ($i=0; $iattributes['sambaSID'][0] = $SID."-".$this->rids[$rids[$i]];
- // Do a check if special grou pis unique
- if ($_SESSION[$_SESSION[$this->base]->cache]->in_cache($SID."-".$this->rids[$rids[$i]], 'sambaSID', 'group'))
- $errors[] = array('ERROR', _('Special Group'),sprintf( _('There can be only one group %s.'), $rids[$i]), 'sambaSID');
+ if (!$profile) {
+ // Get Domain SID from name
+ $sambaDomains = $_SESSION[$_SESSION[$this->base]->ldap]->search_domains($_SESSION[$_SESSION[$this->base]->config]->get_domainSuffix());
+ for ($i=0; $iname) {
+ $SID = $sambaDomains[$i]->SID;
+ $RIDbase = $sambaDomain[$i]->RIDbase;
+ }
+
+ // Load attributes
+ $this->attributes['displayName'][0] = $post['displayName'];
+ $this->attributes['sambaGroupType'][0] = 2;
+
+ $rids = array_keys($this->rids);
+ $wrid = false;
+ for ($i=0; $iattributes['sambaSID'][0] = $SID."-".$this->rids[$rids[$i]];
+ // Do a check if special grou pis unique
+ if ($_SESSION[$_SESSION[$this->base]->cache]->in_cache($SID."-".$this->rids[$rids[$i]], 'sambaSID', 'group'))
+ $errors[] = array('ERROR', _('Special Group'),sprintf( _('There can be only one group %s.'), $rids[$i]), 'sambaSID');
+ }
}
+ if (!$wrid) $this->attributes['sambaSID'][0] = $SID."-".($_SESSION[$this->base]->module['posixGroup']->attributes['gidNumber'][0]*2)+$RIDbase+1;
}
- if (!$wrid) $this->attributes['sambaSID'][0] = $SID."-".($_SESSION[$this->base]->module['posixGroup']->attributes['gidNumber'][0]*2)+$RIDbase+1;
+
// Return error-messages
if (is_array($errors)) return $errors;
return 0;
@@ -222,7 +241,7 @@ class sambaGroupMapping {
* to show a page with all attributes.
* It will output a complete html-table
*/
- function display_html_attributes($post) {
+ function display_html_attributes($post, $profile=false) {
// Get Domain SID from name
$sambaDomains = $_SESSION[$_SESSION[$this->base]->ldap]->search_domains($_SESSION[$_SESSION[$this->base]->config]->get_domainSuffix());
// Get Domain-SID from group SID
@@ -235,42 +254,32 @@ class sambaGroupMapping {
$sel_domain = $sambaDomains[$i]->name;
}
}
- echo "\n";
- return 0;
+ if ($wrid) $options[] = $_SESSION[$this->base]->module['posixGroup']->attributes['cn'][0];
+ else $selected[] = $_SESSION[$this->base]->module['posixGroup']->attributes['cn'][0];
+ $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Windows group') ),
+ 1 => array ( 'kind' => 'select', 'name' => 'sambaSID', 'options' => $options, 'options_selected' => $selected),
+ 2 => array ( 'kind' => 'help', 'value' => 'sambaSID' ));
+ }
+
+ $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Domain') ),
+ 1 => array ( 'kind' => 'select', 'name' => 'sambaDomainName', 'options' => $sambaDomainNames, 'options_selected' => array ( $sel_domain ) ),
+ 2 => array ( 'kind' => 'help', 'value' => 'sambaDomainName' ));
+
+ return $return;
}
function display_html_delete($post) {
diff --git a/lam/lib/modules/sambaSamAccount.inc b/lam/lib/modules/sambaSamAccount.inc
index cbec2c36..74243fa7 100644
--- a/lam/lib/modules/sambaSamAccount.inc
+++ b/lam/lib/modules/sambaSamAccount.inc
@@ -150,6 +150,18 @@ class sambaSamAccount {
return array('attributes', 'sambaUserWorkstations');
}
+ /*
+ */
+ function get_help($id) {
+ switch ($id) {
+ case "description":
+ return array ("ext" => "FALSE", "Headline" => _("Description"),
+ "Text" => _("Host Description."));
+ break;
+ }
+ return false;
+ }
+
/* This function returns all ldap attributes
* which are part of posixAccount and returns
* also their values.
@@ -243,7 +255,7 @@ class sambaSamAccount {
/* Write variables into object and do some regexp checks
*/
- function proccess_attributes($post) {
+ function proccess_attributes($post, $profile=false) {
// Load attributes
$this->attributes['sambaDomainName'][0] = $post['sambaDomainName'];
// Get Domain SID from name
@@ -296,7 +308,7 @@ class sambaSamAccount {
}
if (!$wrid) $this->attributes['sambaPrimaryGroupSID'][0] = $SID."-".($_SESSION[$this->base]->module['posixAccount']->attributes['gidNumber'][0]*2)+$RIDbase+1;
- if (isset($post['sambaLMPassword'])) {
+ if (isset($post['sambaLMPassword']) && !$profile) {
if ($post['sambaLMPassword'] != $post['sambaLMPassword2']) {
$errors[] = array('ERROR', _('Password'), _('Please enter the same password in both password-fields.'), 'sambaLMPassword');
unset ($post['sambaLMPassword2']);
@@ -306,38 +318,58 @@ class sambaSamAccount {
if ($post['useunixpwd']) $this->useunixpwd = true;
else $this->useunixpwd = false;
- if ($post['sambaSID']== _('Administrator')) {
- $this->attributes['sambaSID'][0] = $SID."-500";
- // Do a check if an administrator already exists
- if ($_SESSION[$_SESSION[$this->base]->cache]->in_cache($SID."-500", 'sambaSID', 'user')!=$_SESSION[$this->base]->dn_orig)
- $errors[] = array('ERROR', _('Special user'), _('There can be only one administrator per domain.'), 'sambaSID');
+ if (!$profile) {
+ if ($post['sambaSID']== _('Administrator')) {
+ $this->attributes['sambaSID'][0] = $SID."-500";
+ // Do a check if an administrator already exists
+ if ($_SESSION[$_SESSION[$this->base]->cache]->in_cache($SID."-500", 'sambaSID', 'user')!=$_SESSION[$this->base]->dn_orig)
+ $errors['sambaSID'][] = array('ERROR', _('Special user'), _('There can be only one administrator per domain.'));
+ }
+ if ($post['sambaSID']== _('Guest')) {
+ $this->attributes['sambaSID'][0] = $SID."-501";
+ // Do a check if an administrator already exists
+ if ($_SESSION[$_SESSION[$this->base]->cache]->in_cache($SID."-501", 'sambaSID', 'user')!=$_SESSION[$this->base]->dn_orig)
+ $errors['sambaSID'][] = array('ERROR', _('Special user'), _('There can be only one guest per domain.'));
+ }
+ // Check values
+ $this->attributes['sambaHomePath'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['sambaHomePath'][0]);
+ $this->attributes['sambaHomePath'][0] = str_replace('$group', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['gid'][0], $this->attributes['sambaHomePath'][0]);
+ if ($this->attributes['sambaHomePath'][0] != stripslashes($post['sambaHomePath'])) $errors['sambaHomePath'][] = array('INFO', _('Home path'), _('Inserted user- or groupname in HomePath.'));
+ $this->attributes['sambaLogonScript'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['sambaLogonScript'][0]);
+ $this->attributes['sambaLogonScript'][0] = str_replace('$group', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['gid'][0], $this->attributes['sambaLogonScript'][0]);
+ if ($this->attributes['sambaLogonScript'][0] != stripslashes($post['sambaLogonScript'])) $errors['sambaLogonScript'][] = array('INFO', _('Logon script'), _('Inserted user- or groupname in logon script.'));
+ $this->attributes['sambaProfilePath'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['sambaProfilePath'][0]);
+ $this->attributes['sambaProfilePath'][0] = str_replace('$group', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['gid'][0], $this->attributes['sambaProfilePath'][0]);
+ if ($this->attributes['sambaProfiletPath'][0] != stripslashes($post['sambaProfilePath'])) $errors['sambaProfilePath'][] = array('INFO', _('Profile path'), _('Inserted user- or groupname in profilepath.'));
+ if ( (!$this->attributes['sambaHomePath'][0]=='') && (!ereg('^[\][\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+([\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%]|[?]|[?]|[?]|[?]|[?]|[?]|[?])+)+$', $this->attributes['sambaHomePath'][0])))
+ $errors['sambaHomePath'][] = array('ERROR', _('Home path'), _('Home path is invalid.'));
+ if ( !ereg('^([a-z]|[A-Z]|[0-9]|[\|]|[\#]|[\*]|[\,]|[\.]|[\;]|[\:]|[\_]|[\-]|[\+]|[\!]|[\%]|[\&]|[\/]|[\?]|[\{]|[\[]|[\(]|[\)]|[\]]|[\}])*$',
+ $this->sambaLMPassword())) $errors['sambaLMPassword'][] = array('ERROR', _('Password'), _('Password contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and #*,.;:_-+!$%&/|?{[()]}= !'));
+ if ( (!$this->attributes['sambaLogonScript'][0]=='') && (!ereg('^([/])*([a-z]|[0-9]|[.]|[-]|[_]|[%]|[?]|[?]|[?]|[?]|[?]|[?]|[?])+([a-z]|[0-9]|[.]|[-]|[_]|[%]|[?]|[?]|[?]|[?]|[?]|[?]|[?])*'.
+ '([/]([a-z]|[0-9]|[.]|[-]|[_]|[%]|[?]|[?]|[?]|[?]|[?]|[?]|[?])+([a-z]|[0-9]|[.]|[-]|[_]|[%]|[?]|[?]|[?]|[?]|[?]|[?]|[?])*)*(([.][b][a][t])|([.][c][m][d]))$', $this->attributes['sambaLogonScript'][0])))
+ $errors['sambaScriptPath'][] = array('ERROR', _('Script path'), _('Script path is invalid!'));
+ if ( (!$this->attributes['sambaProfilePath'][0]=='') && (!ereg('^[/][a-z]([a-z]|[0-9]|[.]|[-]|[_]|[%])*([/][a-z]([a-z]|[0-9]|[.]|[-]|[_]|[%])*)*$', $this->attributes['sambaProfilePath'][0]))
+ && (!ereg('^[\][\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+([\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+)+$', $this->attributes['sambaProfilePath'][0])))
+ $errors['sambaProfilePath'][] = array('ERROR', _('Profile path'), _('Profile path is invalid!'));
}
- if ($post['sambaSID']== _('Guest')) {
- $this->attributes['sambaSID'][0] = $SID."-501";
- // Do a check if an administrator already exists
- if ($_SESSION[$_SESSION[$this->base]->cache]->in_cache($SID."-501", 'sambaSID', 'user')!=$_SESSION[$this->base]->dn_orig)
- $errors[] = array('ERROR', _('Special user'), _('There can be only one guest per domain.'), 'sambaSID');
+ else {
+ $sambaHomePath = str_replace('$user', 'user', $this->attributes['sambaHomePath'][0]);
+ $sambaHomePath = str_replace('$group', 'group', $sambaHomePath);
+ $sambaLogonScript = str_replace('$user', 'user', $this->attributes['sambaLogonScript'][0]);
+ $sambaLogonScript = str_replace('$group', 'group', $sambaLogonScript);
+ $sambaProfilePath = str_replace('$user', 'user', $this->attributes['sambaProfilePath'][0]);
+ $sambaProfilePath = str_replace('$group', 'group', $sambaProfilePath);
+ if ( (!$this->attributes['sambaHomePath'][0]=='') && (!ereg('^[\][\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+([\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%]|[?]|[?]|[?]|[?]|[?]|[?]|[?])+)+$', $this->attributes['sambaHomePath'][0])))
+ $errors[] = array('ERROR', _('Home path'), _('Home path is invalid.'), 'sambaHomePath');
+ if ( !ereg('^([a-z]|[A-Z]|[0-9]|[\|]|[\#]|[\*]|[\,]|[\.]|[\;]|[\:]|[\_]|[\-]|[\+]|[\!]|[\%]|[\&]|[\/]|[\?]|[\{]|[\[]|[\(]|[\)]|[\]]|[\}])*$',
+ $this->sambaLMPassword())) $errors[] = array('ERROR', _('Password'), _('Password contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and #*,.;:_-+!$%&/|?{[()]}= !'), 'sambaLMPassword');
+ if ( (!$this->attributes['sambaLogonScript'][0]=='') && (!ereg('^([/])*([a-z]|[0-9]|[.]|[-]|[_]|[%]|[?]|[?]|[?]|[?]|[?]|[?]|[?])+([a-z]|[0-9]|[.]|[-]|[_]|[%]|[?]|[?]|[?]|[?]|[?]|[?]|[?])*'.
+ '([/]([a-z]|[0-9]|[.]|[-]|[_]|[%]|[?]|[?]|[?]|[?]|[?]|[?]|[?])+([a-z]|[0-9]|[.]|[-]|[_]|[%]|[?]|[?]|[?]|[?]|[?]|[?]|[?])*)*(([.][b][a][t])|([.][c][m][d]))$', $this->attributes['sambaLogonScript'][0])))
+ $errors[] = array('ERROR', _('Script path'), _('Script path is invalid!'), 'sambaScriptPath');
+ if ( (!$this->attributes['sambaProfilePath'][0]=='') && (!ereg('^[/][a-z]([a-z]|[0-9]|[.]|[-]|[_]|[%])*([/][a-z]([a-z]|[0-9]|[.]|[-]|[_]|[%])*)*$', $this->attributes['sambaProfilePath'][0]))
+ && (!ereg('^[\][\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+([\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+)+$', $this->attributes['sambaProfilePath'][0])))
+ $errors[] = array('ERROR', _('Profile path'), _('Profile path is invalid!'), 'sambaProfilePath');
}
- // Check values
- $this->attributes['sambaHomePath'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['sambaHomePath'][0]);
- $this->attributes['sambaHomePath'][0] = str_replace('$group', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['gid'][0], $this->attributes['sambaHomePath'][0]);
- if ($this->attributes['sambaHomePath'][0] != stripslashes($post['sambaHomePath'])) $errors[] = array('INFO', _('Home path'), _('Inserted user- or groupname in HomePath.'), 'sambaHomePath');
- $this->attributes['sambaLogonScript'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['sambaLogonScript'][0]);
- $this->attributes['sambaLogonScript'][0] = str_replace('$group', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['gid'][0], $this->attributes['sambaLogonScript'][0]);
- if ($this->attributes['sambaLogonScript'][0] != stripslashes($post['sambaLogonScript'])) $errors[] = array('INFO', _('Logon script'), _('Inserted user- or groupname in logon script.'), 'sambaLogonScript');
- $this->attributes['sambaProfilePath'][0] = str_replace('$user', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['uid'][0], $this->attributes['sambaProfilePath'][0]);
- $this->attributes['sambaProfilePath'][0] = str_replace('$group', $_SESSION[$this->base]->module['inetOrgPerson']->attributes['gid'][0], $this->attributes['sambaProfilePath'][0]);
- if ($this->attributes['sambaProfiletPath'][0] != stripslashes($post['sambaProfilePath'])) $errors[] = array('INFO', _('Profile path'), _('Inserted user- or groupname in profilepath.'), 'sambaProfilePath');
- if ( (!$this->attributes['sambaHomePath'][0]=='') && (!ereg('^[\][\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+([\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%]|[?]|[?]|[?]|[?]|[?]|[?]|[?])+)+$', $this->attributes['sambaHomePath'][0])))
- $errors[] = array('ERROR', _('Home path'), _('Home path is invalid.'), 'sambaHomePath');
- if ( !ereg('^([a-z]|[A-Z]|[0-9]|[\|]|[\#]|[\*]|[\,]|[\.]|[\;]|[\:]|[\_]|[\-]|[\+]|[\!]|[\%]|[\&]|[\/]|[\?]|[\{]|[\[]|[\(]|[\)]|[\]]|[\}])*$',
- $this->sambaLMPassword())) $errors[] = array('ERROR', _('Password'), _('Password contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and #*,.;:_-+!$%&/|?{[()]}= !'), 'sambaLMPassword');
- if ( (!$this->attributes['sambaLogonScript'][0]=='') && (!ereg('^([/])*([a-z]|[0-9]|[.]|[-]|[_]|[%]|[?]|[?]|[?]|[?]|[?]|[?]|[?])+([a-z]|[0-9]|[.]|[-]|[_]|[%]|[?]|[?]|[?]|[?]|[?]|[?]|[?])*'.
- '([/]([a-z]|[0-9]|[.]|[-]|[_]|[%]|[?]|[?]|[?]|[?]|[?]|[?]|[?])+([a-z]|[0-9]|[.]|[-]|[_]|[%]|[?]|[?]|[?]|[?]|[?]|[?]|[?])*)*(([.][b][a][t])|([.][c][m][d]))$', $this->attributes['sambaLogonScript'][0])))
- $errors[] = array('ERROR', _('Script path'), _('Script path is invalid!'), 'sambaScriptPath');
- if ( (!$this->attributes['sambaProfilePath'][0]=='') && (!ereg('^[/][a-z]([a-z]|[0-9]|[.]|[-]|[_]|[%])*([/][a-z]([a-z]|[0-9]|[.]|[-]|[_]|[%])*)*$', $this->attributes['sambaProfilePath'][0]))
- && (!ereg('^[\][\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+([\]([a-z]|[A-Z]|[0-9]|[.]|[-]|[%])+)+$', $this->attributes['sambaProfilePath'][0])))
- $errors[] = array('ERROR', _('Profile path'), _('Profile path is invalid!'), 'sambaProfilePath');
}
if (is_array($errors)) return $errors;
if ($post['sambaUserWorkstations']) return 'sambaUserWorkstations';
@@ -346,48 +378,50 @@ class sambaSamAccount {
/* Write variables into object and do some regexp checks
*/
- function proccess_sambaUserWorkstations($post) {
+ function proccess_sambaUserWorkstations($post, $profile=false) {
// Load attributes
- do { // X-Or, only one if() can be true
- if (isset($post['availableSambaUserWorkstations']) && isset($post['sambaUserWorkstations_add'])) { // Add workstations to list
- $temp = str_replace(' ', '', $this->attributes['sambaUserWorkstations'][0]);
- $workstations = explode (',', $temp);
- for ($i=0; $iattributes['sambaUserWorkstations'][0] = $workstations[0];
- for ($i=1; $iattributes['sambaUserWorkstations'][0] = $this->attributes['sambaUserWorkstations'][0] . "," . $workstations[$i];
+ if ($_SESSION[$this->base]->type=='user') {
+ do { // X-Or, only one if() can be true
+ if (isset($post['availableSambaUserWorkstations']) && isset($post['sambaUserWorkstations_add'])) { // Add workstations to list
+ $temp = str_replace(' ', '', $this->attributes['sambaUserWorkstations'][0]);
+ $workstations = explode (',', $temp);
+ for ($i=0; $iattributes['sambaUserWorkstations'][0] = $workstations[0];
+ for ($i=1; $iattributes['sambaUserWorkstations'][0] = $this->attributes['sambaUserWorkstations'][0] . "," . $workstations[$i];
+ }
+ break;
}
- break;
- }
- if (isset($post['sambaUserWorkstations']) && isset($post['sambaUserWorkstations_remove'])) { // remove // Add workstations from list
- // Put all workstations in array
- $temp = str_replace(' ', '', $this->attributes['sambaUserWorkstations'][0]);
- $workstations = explode (',', $temp);
- for ($i=0; $iattributes['sambaUserWorkstations'][0] = $workstations[0];
- for ($i=1; $iattributes['sambaUserWorkstations'][0] = $this->attributes['sambaUserWorkstations'][0] . "," . $workstations[$i];
+ if (isset($post['sambaUserWorkstations']) && isset($post['sambaUserWorkstations_remove'])) { // remove // Add workstations from list
+ // Put all workstations in array
+ $temp = str_replace(' ', '', $this->attributes['sambaUserWorkstations'][0]);
+ $workstations = explode (',', $temp);
+ for ($i=0; $iattributes['sambaUserWorkstations'][0] = $workstations[0];
+ for ($i=1; $iattributes['sambaUserWorkstations'][0] = $this->attributes['sambaUserWorkstations'][0] . "," . $workstations[$i];
+ }
+ break;
}
- break;
- }
- } while(0);
- if ($post['attributes']) return 'attributes';
+ } while(0);
+ if ($post['attributes']) return 'attributes';
+ }
return 0;
}
@@ -395,7 +429,7 @@ class sambaSamAccount {
* to show a page with all attributes.
* It will output a complete html-table
*/
- function display_html_attributes($post) {
+ function display_html_attributes($post, $profile=false) {
// Get Domain SID from name
$sambaDomains = $_SESSION[$_SESSION[$this->base]->ldap]->search_domains($_SESSION[$_SESSION[$this->base]->config]->get_domainSuffix());
for ($i=0; $iattributes['sambaDomainName'][0] == $sambaDomains[$i]->name)
$SID = $sambaDomains[$i]->SID;
}
+ $canchangedate = getdate($this->attributes['sambaPwdCanChange'][0]);
+ $mustchangedate = getdate($this->attributes['sambaPwdMustChange'][0]);
+
if ($_SESSION[$this->base]->type=='user') {
- $canchangedate = getdate($this->attributes['sambaPwdCanChange'][0]);
- $mustchangedate = getdate($this->attributes['sambaPwdMustChange'][0]);
- echo ''.
- ''.
- ''.
- ''.
- ''.
- ''.
- '';
- echo "\n\n";
- echo " \n";
- echo "" . _('Samba password') . " | \n";
- echo "sambaLMPassword() . "\"> | \n";
- echo " \n";
- echo "\n";
- echo "" . _('Repeat password') . " | \n";
- echo "sambaLMPassword();
- echo "\"> | \n";
- echo " | \n";
- echo " \n";
- if ($_SESSION[$this->base]->module['posixAccount']->orig['userPassword'][0] != $_SESSION[$this->base]->module['posixAccount']->attributes['userPassword'][0]) {
- echo "\n";
- echo "" . _('Use unix password') . " | \n";
- echo "useunixpwd) echo " checked ";
- echo "> | \n";
- echo "" . _('Help') . " | ";
- echo " \n";
+ $return[] = array ( 0 => array ( 'kind' => 'input', 'name' => 'sambaPwdCanChange_h', 'type' => 'hidden', 'value' => $canchangedate['hours']),
+ 1 => array ( 'kind' => 'input', 'name' => 'sambaPwdCanChange_m', 'type' => 'hidden', 'value' => $canchangedate['minutes']),
+ 2 => array ( 'kind' => 'input', 'name' => 'sambaPwdCanChange_s', 'type' => 'hidden', 'value' => $canchangedate['seconds']),
+ 3 => array ( 'kind' => 'input', 'name' => 'sambaPwdMustChange_h', 'type' => 'hidden', 'value' => $mustchangedate['hours']),
+ 4 => array ( 'kind' => 'input', 'name' => 'sambaPwdMustChange_m', 'type' => 'hidden', 'value' => $mustchangedate['minutes']),
+ 5 => array ( 'kind' => 'input', 'name' => 'sambaPwdMustChange_s', 'type' => 'hidden', 'value' => $mustchangedate['seconds']),
+ 6 => array ( 'kind' => 'input', 'name' => 'sambaAcctFlagsU', 'type' => 'hidden', 'value' => 'true'));
+ if (!$profile) {
+ if ($this->attributes['lmPassword'][0] != $this->orig['lmPassword'][0]) $password=$this->sambaLMPassword();
+ else $password='';
+ $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Samba password') ),
+ 1 => array ( 'kind' => 'input', 'name' => 'sambaLMPassword', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => $password));
+ if ($post['sambaLMPassword2']!='') $password2 = $post['sambaLMPassword2'];
+ $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Repeat password') ),
+ 1 => array ( 'kind' => 'input', 'name' => 'sambaLMPassword2', 'type' => 'password', 'size' => '20', 'maxlength' => '255', 'value' => $password2),
+ 2 => array ('kind' => 'help', 'value' => 'sambaLMPassword'));
}
- echo "\n";
- echo "" . _('Use no password') . " | \n";
- echo "attributes['sambaAcctFlags'][0], "N")) echo " checked ";
- echo "> | \n";
- echo "" . _('Help' ) ." | \n";
- echo " \n";
- echo "\n";
- echo "" . _('Password does not expire') . " | \n";
- echo "attributes['sambaAcctFlags'][0], "X")) echo " checked ";
- echo "> | \n";
- echo "" . _('Help') . " | \n";
- echo " \n";
- echo "\n";
- echo "" . _('User can change password') . " | \n";
- echo " | \n";
- echo "" . _('Help') . " | \n";
- echo " \n";
- echo "\n";
- echo "" . _('User must change password') . " | \n";
- echo " | \n";
- echo "" . _('Help') . " | \n";
- echo " \n";
- echo "\n";
- echo "" . _('Account is deactivated') . " | \n";
- echo "attributes['sambaAcctFlags'][0], "D")) echo " checked ";
- echo "> | \n";
- echo "" . _('Help') . " | \n";
- echo " \n";
- echo "\n";
- echo "" . _('Home drive') . " | \n";
- echo " | \n";
- echo "" . _('Help') . " | \n";
- echo " \n";
- echo "\n";
- echo "" . _('Home path') . " | \n";
- echo "attributes['sambaHomePath'][0] . "\"> | \n";
- echo "" . _('Help') . " | \n";
- echo " \n";
- echo "\n";
- echo "" . _('Profile path') . " | \n";
- echo "attributes['sambaProfilePath'][0] . "\"> | \n";
- echo "" . _('Help') . " | \n";
- echo " \n";
- echo "\n";
- echo "" . _('Logon script') . " | \n";
- echo "attributes['sambaLogonScript'][0] . "\"> | \n";
- echo "" . _('Help') . " | \n";
- echo " \n";
- echo "\n";
- echo "" . _('Samba workstations') . " | \n";
- echo " | \n";
- echo "" . _('Help') . " | \n";
- echo " \n";
- echo "\n";
- echo "" . _('Windows group') . " | \n";
- echo " | \n";
- echo "" . _('Help') . " | \n";
- echo " \n";
- echo "\n";
- echo "" . _('Special user') . " | \n";
- echo " | \n";
- echo "" . _('Help-XX') . " | \n";
- echo " \n";
- echo "\n";
- echo "" . _('Domain') . " | \n";
- echo " | \n";
- echo "" . _('Help') . " | \n";
- echo " \n";
- echo " \n";
+ else $options[] = _('Guest');
+ if ($wrid) $options[] = _('Ordinary user');
+ else $selected[] = _('Ordinary user');
+ $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Special user') ),
+ 1 => array ( 'kind' => 'select', 'name' => 'sambaSID', 'options' => $options, 'options_selected' => $selected),
+ 2 => array ( 'kind' => 'help', 'value' => 'sambaSID' ));
+ }
+ $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Domain') ),
+ 1 => array ( 'kind' => 'select', 'name' => 'sambaDomainName', 'options' => $sambaDomainNames, 'options_selected' => array($this->attributes['sambaDomainName'][0])),
+ 2 => array ( 'kind' => 'help', 'value' => 'sambaDomainName' ));
}
if ($_SESSION[$this->base]->type=='host') {
- echo '';
- echo "\n";
+ $return[] = array ( 0 => array ( 'kind' => 'input', 'name' => 'sambaAcctFlagsW', 'type' => 'hidden', 'value' => 'true' ));
+ if (!$profile) {
+ $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Reset password') ),
+ 1 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'ResetSambaPassword'),
+ 2 => array ( 'kind' => 'help', 'value' => 'ResetSambaPassword' ));
+ }
+ $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Domain') ),
+ 1 => array ( 'kind' => 'select', 'name' => 'sambaDomainName', 'options' => $sambaDomainNames, 'options_selected' => $this->attributes['sambaDomainName'][0]),
+ 2 => array ( 'kind' => 'help', 'value' => 'sambaDomainName' ));
}
- return 0;
+ return $return;
}
function display_html_delete($post) {
@@ -605,52 +573,33 @@ class sambaSamAccount {
* to show a page with all attributes.
* It will output a complete html-table
*/
- function display_html_sambaUserWorkstations($post) {
- // Get list of all hosts.
- $result = $_SESSION[$_SESSION[$this->base]->cache]->get_cache('uid', 'sambaSamAccount', 'host');
- if (is_array($result)) {
- foreach ($result as $host) $availableUserWorkstations[] = str_replace("$", '', $host[0]);
- sort($availableUserWorkstations, SORT_STRING);
- $result = str_replace(' ', '', $this->attributes['sambaUserWorkstations'][0]);
- $userWorkstations = explode (',', $result);
- $availableUserWorkstations = array_delete($userWorkstations, $availableUserWorkstations);
+ function display_html_sambaUserWorkstations($post, $profile=false) {
+ if ($_SESSION[$this->base]->type=='user') {
+ // Get list of all hosts.
+ $result = $_SESSION[$_SESSION[$this->base]->cache]->get_cache('uid', 'sambaSamAccount', 'host');
+ if (is_array($result)) {
+ foreach ($result as $host) $availableUserWorkstations[] = str_replace("$", '', $host[0]);
+ sort($availableUserWorkstations, SORT_STRING);
+ $result = str_replace(' ', '', $this->attributes['sambaUserWorkstations'][0]);
+ $userWorkstations = explode (',', $result);
+ $availableUserWorkstations = array_delete($userWorkstations, $availableUserWorkstations);
+ }
+
+ $return[] = array ( 0 => array ( 'kind' => 'fieldset', 'legend' => _("Allowed workstations"), 'value' =>
+ array ( 0 => array ( 0 => array ('kind' => 'fieldset', 'td' => array ('valign' => 'top'), 'legend' => _("Allowed workstations"), 'value' =>
+ array ( 0 => array ( 0 => array ( 'kind' => 'select', 'name' => 'sambaUserWorkstations[]', 'size' => '15', 'multiple', 'options' => $userWorkstations)))),
+ 1 => array ( 'kind' => 'table', 'value' => array ( 0 => array ( 0 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'sambaUserWorkstations_add',
+ 'value' => '<=')), 1 => array ( 0 => array ( 'kind' => 'input', 'type' => 'submit', 'name' => 'sambaUserWorkstations_remove', 'value' => '=>' )),
+ 2 => array ( 0 => array ( 'kind' => 'help', 'value' => 'sambaUserWorkstations' )))),
+ 2 => array ('kind' => 'fieldset', 'td' => array ('valign' => 'top'), 'legend' => _("Available workstations"), 'value' =>
+ array ( 0 => array ( 0 => array ( 'kind' => 'select', 'name' => 'availableSambaUserWorkstations[]', 'size' => '15', 'multiple', 'options' => $availableUserWorkstations))))
+ ))));
+
+ $return[] = array ( 0 => array ( 'kind' => 'input', 'type' => 'submit', 'value' => _('Back') ),
+ 1 => array ( 'kind' => 'text'),
+ 2 => array ('kind' => 'text'));
}
- echo "\n";
+ return $return;
}
}
diff --git a/lam/lib/modules/shadowAccount.inc b/lam/lib/modules/shadowAccount.inc
index cdbc9271..d840c3af 100644
--- a/lam/lib/modules/shadowAccount.inc
+++ b/lam/lib/modules/shadowAccount.inc
@@ -111,6 +111,18 @@ class shadowAccount {
return array('attributes');
}
+ /*
+ */
+ function get_help($id) {
+ switch ($id) {
+ case "description":
+ return array ("ext" => "FALSE", "Headline" => _("Description"),
+ "Text" => _("Host Description."));
+ break;
+ }
+ return false;
+ }
+
/* This function returns all ldap attributes
* which are part of shadowAccount and returns
* also their values.
@@ -168,7 +180,7 @@ class shadowAccount {
/* Write variables into object and do some regexp checks
*/
- function proccess_attributes($post) {
+ function proccess_attributes($post, $profile=false) {
// Load attributes
$this->attributes['shadowMin'][0] = $post['shadowMin'];
$this->attributes['shadowMax'][0] = $post['shadowMax'];
@@ -191,51 +203,36 @@ class shadowAccount {
* to show a page with all attributes.
* It will output a complete html-table
*/
- function display_html_attributes($post) {
+ function display_html_attributes($post, $profile=false) {
// Use dd-mm-yyyy format of date because it's easier to read for humans
$date = getdate ($this->attributes['shadowExpire'][0]*3600*24);
- echo "\n";
- return 0;
+
+ $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Password warn') ),
+ 1 => array ( 'kind' => 'input', 'name' => 'shadowWarning', 'type' => 'text', 'size' => '4', 'maxlength' => '4', 'value' => $this->attributes['shadowWarning'][0] ),
+ 2 => array ( 'kind' => 'help', 'value' => 'shadowWarning' ));
+ $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Password expire') ),
+ 1 => array ( 'kind' => 'input', 'name' => 'shadowInactive', 'type' => 'text', 'size' => '4', 'maxlength' => '4', 'value' => $this->attributes['shadowInactive'][0] ),
+ 2 => array ( 'kind' => 'help', 'value' => 'shadowInactive' ));
+ $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Maximum password age') ),
+ 1 => array ( 'kind' => 'input', 'name' => 'shadowMax', 'type' => 'text', 'size' => '5', 'maxlength' => '5', 'value' => $this->attributes['shadowMax'][0] ),
+ 2 => array ( 'kind' => 'help', 'value' => 'shadowMax' ));
+ $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Minimum password age') ),
+ 1 => array ( 'kind' => 'input', 'name' => 'shadowMin', 'type' => 'text', 'size' => '5', 'maxlength' => '5', 'value' => $this->attributes['shadowMin'][0] ),
+ 2 => array ( 'kind' => 'help', 'value' => 'shadowMin' ));
+
+ for ( $i=1; $i<=31; $i++ ) $mday[] = $i;
+ for ( $i=1; $i<=12; $i++ ) $mon[] = $i;
+ for ( $i=2003; $i<=2030; $i++ ) $year[] = $i;
+ $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Expire day') ),
+ 1 => array ( 'kind' => 'table', 'value' => array ( 0 => array ( 0 => array ( 'kind' => 'select', 'name' => 'shadowExpire_day',
+ 'options' => $mday, 'options_selectd' => $date['mday']),
+ 1 => array ( 'kind' => 'select', 'name' => 'shadowExpire_mon',
+ 'options' => $mon, 'options_selectd' => $date['mon']),
+ 2 => array ( 'kind' => 'select', 'name' => 'shadowExpire_yea',
+ 'options' => $year, 'options_selectd' => $date['year'])))),
+ 2 => array ( 'kind' => 'help', 'value' => 'shadowExpire' ));
+
+ return $return;
}
function display_html_delete($post) {
|