Finished first module

This commit is contained in:
katagia 2003-12-12 18:21:15 +00:00
parent 6b9089eb85
commit e7a122d45a
2 changed files with 218 additions and 178 deletions

View File

@ -54,7 +54,7 @@ class cache {
}
$scopes = array_keys($attributes);
foreach ($scopes as $scope) {
if (!@in_array($scope, $allowed_types)) trigger_error(sprintf(_('Invalid scope. Valid scopes are $s.'), implode(" ", $allowed_types)), E_USER_ERROR);
if (!@in_array($scope, $allowed_types)) trigger_error(sprintf(_('Invalid scope. Valid scopes are %s.'), implode(" ", $allowed_types)), E_USER_ERROR);
}
// Everything seems to be OK, start processing data
foreach ($scopes as $scope) {
@ -76,7 +76,7 @@ class cache {
if (strpos($_SESSION['ldap']->objectClasses[$i], "NAME '$objectClass'")) $line = $i;
}
// Return error if objectClass isn't found
if ($line==-1) trigger_error (_("objectClass $objectClass required but not defined in ldap."), E_USER_WARNING);
if ($line==-1) trigger_error (sprintf(_("objectClass %s required but not defined in ldap."), $objectClass), E_USER_WARNING);
// Everything seems to be OK, start processing data
$this->refresh_cache();
if ($singlescope == '*') $scopes = $allowed_types;
@ -231,7 +231,7 @@ class accountContainer {
var $type;
var $lampath; // reference to lampath from Session
var $ldap; // This is a reference to the ldap class in session
var $modules; // This is an array with all module objects
var $module; // This is an array with all module objects
/* Get the type of account. Valid
* types are: user, group, host
@ -249,7 +249,7 @@ class accountContainer {
if (strpos($this->ldap->objectClasses[$i], "NAME '$objectClass'")) $line = $i;
}
// Return error if objectClass isn't found
if ($line==-1) trigger_error (_("objectClass objectClass required but not defined in ldap."), E_USER_WARNING);
if ($line==-1) trigger_error (sprintf(_("objectClass %s required but not defined in ldap."), $objectClass), E_USER_WARNING);
// create array with must-attributes
// Get startposition in string
if (strpos($this->ldap->objectClasses[$line], 'MUST (')) {
@ -288,7 +288,7 @@ class accountContainer {
if (strpos($this->ldap->objectClasses[$i], "NAME '$subclass'")) $line = $i;
}
// Return error if objectClass isn't found
if ($line==-1) trigger_error (_("objectClass objectClass required but not defined in ldap."), E_USER_WARNING);
if ($line==-1) trigger_error (sprintf(_("objectClass %s required but not defined in ldap."), $objectClass), E_USER_WARNING);
// create array with must-attributes
// Get startposition in string
@ -348,12 +348,12 @@ class accountContainer {
if (strpos($_SESSION['ldap']->objectClasses[$i], "NAME '$objectClass'")) $line = $i;
}
// Return error if objectClass isn't found
if ($line==-1) trigger_error (_("objectClass objectClass required but not defined in ldap."), E_USER_WARNING);
if ($line==-1) trigger_error (_("objectClass $objectClass required but not defined in ldap."), E_USER_WARNING);
else {
// Add module if it exists
if (filetype($this->lampath."/lib/modules/".$objectClass.".inc") == 'file') {
include_once ($this->lampath."/lib/modules/".$objectClass.".inc");
$this->modules[] = new $objectClass($this);
$this->module[$objectClass] = new $objectClass($this);
}
}
return 0;

View File

@ -28,7 +28,7 @@ $Id$
* dn_orig: old DN if account was loaded with uid= or cn=
* External functions which are used
* account.inc: array_delete
* account.inc:
*/
@ -131,7 +131,7 @@ class inetOrgPerson {
}
}
}
$this->attributes = $this->orig;
$this->orig = $this->attributes ;
$this->alias = _('inetOrgPerson');
}
@ -140,7 +140,11 @@ class inetOrgPerson {
var $alias;
// reference to base-array so we can read other classes in basearray
var $base;
// This variable contains all inetOrgPerson Attributes
// Use a unix password?
var $userPassword_no;
// Lock account?
var $userPassword_lock;
// This variable contains all inetOrgPerson attributes
var $attributes;
/* If an account was loaded all attributes are kept in this array
* to compare it with new changed attributes
@ -149,7 +153,31 @@ class inetOrgPerson {
/* $attribute['password'] can't accessed directly because it's enrcypted
* To read / write password function userPassword is needed
*/
/* This function will return the unencrypted password when
* called without a variable
* If it's called with a new password, the
* new password will be stored encrypted
*/
function userPassword($newpassword=false) {
// Read existing password if set
if (!$newpassword) {
if ($this->attributes['userPassword'][0]!='') {
$iv = base64_decode($_COOKIE["IV"]);
$key = base64_decode($_COOKIE["Key"]);
$password = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, base64_decode($this->attributes['userPassword'][0]), MCRYPT_MODE_ECB, $iv);
$password = str_replace(chr(00), '', $password);
return $password;
}
else return '';
}
// Write new password
else {
$iv = base64_decode($_COOKIE["IV"]);
$key = base64_decode($_COOKIE["Key"]);
$this->attributes['userPassword'][0] = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $newpassword, MCRYPT_MODE_ECB, $iv));
return 0;
}
}
/* This function returns a list with all required modules
*/
@ -162,16 +190,45 @@ class inetOrgPerson {
*/
function proccess_attributes() {
// Load attributes
if (($this->attributes['uid'] != $_POST['form_inetOrgPerson_uid']) && ereg('[A-Z]$', $_POST['form_inetOrgPerson_uid']))
$errors[] = array('WARN', _('Username'), _('You are using a capital letters. This can cause problems because windows isn\'t case-sensitive.'));
$this->attributes['uid'] = $_POST['form_inetOrgPerson_uid'];
$this->attributes['cn'] &= $this->attributes['cn'];
$this->attributes['cn'] &= $this->attributes['uid'];
$this->attributes['description'] = $_POST['form_inetOrgPerson_description'];
$this->attributes['sn'] = $_POST['form_inetOrgPerson_sn'];
$this->attributes['givenName'] = $_POST['form_inetOrgPerson_givenName'];
$this->attributes['title'] = $_POST['form_inetOrgPerson_title'];
$this->attributes['mail'] = $_POST['form_inetOrgPerson_mail'];
$this->attributes['telephoneNumber'] = $_POST['form_inetOrgPerson_telephoneNumber'];
$this->attributes['mobileTelephoneNumber'] = $_POST['form_inetOrgPerson_mobileTelephoneNumber'];
$this->attributes['facsimileTelephoneNumber'] = $_POST['form_inetOrgPerson_facsimileTelephoneNumber'];
$this->attributes['street'] = $_POST['form_inetOrgPerson_street'];
$this->attributes['postalCode'] = $_POST['form_inetOrgPerson_postalCode'];
$this->attributes['postalAddress'] = $_POST['form_inetOrgPerson_postalAddress'];
$this->attributes['employeeType'] = $_POST['form_inetOrgPerson_employeeType'];
if ($_POST['form_inetOrgPerson_userPassword_no']; $this->userPassword_no=true;
else $this->userPassword_no=false;
if ($_POST['form_inetOrgPerson_userPassword_lock']; $this->userPassword_lock=true;
else $this->userPassword_lock=false;
if (isset($_POST['form_inetOrgPerson_userPassword'])) {
if ($_POST['form_inetOrgPerson_userPassword'] != $_POST['form_inetOrgPerson_userPassword2']) {
$errors[] = array('ERROR', _('Password'), _('Please enter the same password in both password-fields.'));
unset ($_POST['form_inetOrgPerson_userPassword2']);
}
else $this->userPassword($_POST['form_inetOrgPerson_userPassword']);
}
if ($_POST['form_inetOrgPerson_genpass']) $this->userPassword(genpasswd());
// Check if givenname is valid
if ( !ereg('^([a-z]|[A-Z]|[-]|[ ]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+$', $this->attributes['givenName'])) $errors[] = array('ERROR', _('Given name'), _('Given name contains invalid characters'));
// Check if surname is valid
if ( !ereg('^([a-z]|[A-Z]|[-]|[ ]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+$', $this->attributes['sn'])) $errors[] = array('ERROR', _('Surname'), _('Surname contains invalid characters'));
// Check if Username contains only valid characters
if ( !ereg('^([a-z]|[A-Z]|[0-9]|[.]|[-]|[_])*$', $this->attributes['uid']))
$errors[] = array('ERROR', _('Username'), _('Username 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
// *** fixme make incache modularized. Incache will return the found attribute
// Set username back to original name if new username is in use
if (incache($this->attributes['uid'],'uid', '*')!=$this->orig['uid'] && ($this->orig['uid']!='')) $this->attributes['uid'] = $this->orig['uid'];
// Change uid to a new uid until a free uid is found
@ -207,8 +264,18 @@ class inetOrgPerson {
}
// Show warning if lam has changed username
if ($this->attributes['uid'] != $_POST['form_inetOrgPerson_uid']) $errors[] = array('WARN', _('Username'), _('Username in use. Selected next free username.'));
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 #*,.;:_-+!$%&/|?{[()]}= !'));
if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/]|[-])*$', $this->attributes['telephoneNumber'])) $errors[] = array('ERROR', _('Telephone number'), _('Please enter a valid telephone number!'));
if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/]|[-])*$', $this->attributes['mobileTelephoneNumber'])) $errors[] = array('ERROR', _('Mobile number'), _('Please enter a valid mobile number!'));
if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/]|[-])*$', $this->attributes['facsimileTelephoneNumber'])) $errors[] = 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'])) $errors[] = array('ERROR', _('eMail address'), _('Please enter a valid eMail address!'));
if ( !ereg('^([0-9]|[A-Z]|[a-z]|[-]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $this->attributes['street'])) $errors[] = array('ERROR', _('Street'), _('Please enter a valid street name!'));
if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $this->attributes['postalAddress'])) $errors[] = array('ERROR', _('Postal address'), _('Please enter a valid postal address!'));
if ( !ereg('^([0-9]|[A-Z]|[a-z]|[-]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $this->attributes['title'])) $errors[] = array('ERROR', _('Title'), _('Please enter a valid title!'));
if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $this->attributes['employeeType'])) $errors[] = array('ERROR', _('Employee type'), _('Please enter a valid employee type!'));
if ( !ereg('^([0-9]|[A-Z]|[a-z])*$', $this->attributes['personal_postalCode'])) $errors[] = array('ERROR', _('Postal code'), _('Please enter a valid postal code!'));
// Return error-messages
if (is_array($errors)) return $errors;
return 0;
@ -219,7 +286,24 @@ class inetOrgPerson {
*/
function load_attributes($attr) {
// Load attributes which are displayed
// unset count entries
unset ($attr['count']);
$attributes = array_keys($attr);
foreach ($attributes as $attribute) unset ($attr[$attribute]['count']);
// unset double entries
for ($i=0; $i<count($attr); $i++)
if (isset($attr[$i])) unset($attr[$i]);
foreach ($attributes as $attribute) {
if (isset($this->attributes[$attribute])) {
// decode as unicode
for ($i=0; $i<count($this->attributes[$attribute]); $i++) $this->attributes[$attribute][$i] = utf8_decode ($this->attributes[$attribute][$i]);
$this->attributes[$attribute] = $attr[$attribute];
}
}
// Values are kept as copy so we can compare old attributes with new attributes
$this->orig = $this->attributes;
$this->userPassword(''); // Remove old password so it won't displayed as hash
return 0;
}
@ -230,80 +314,74 @@ class inetOrgPerson {
* e.g. create a new user and add him to some groups via attribute memberUid
* add are attributes which have to be added to ldap entry
* remove are attributes which have to be removed from ldap entry
* modify are attributes which have to been modified in ldap entry
*/
function save_attributes() {
/* Exmaples
* Add new attribute
* if ($this->cn!='' && $this->orig['cn']=='') $return[$this->base['dn']]['add']['cn'] = $this->cn;
* Modify existing attribute
* if ($this->cn!='' && $this->orig['cn']!='') $return[$this->base['dn']]['modify']['cn'] = $this->cn;
* Remove existing attribute
* if ($this->cn=='' && $this->orig['cn']!='') $return[$this->base['dn']]['remove']['cn'] = $this->cn;
*/
// Get list off all attributes
$attributes = $this->orig;
// Remove attributes which are not as easy to set
unset ($attributes['enc_userPassword']);
unset ($attributes['groups']);
unset ($attributes['userPassword']);
// Get list of all "easy" attributes
$attr_names = array_keys($attributes);
foreach ($attr_names as $attr_name) {
if ($this->$attr_name!='' && $this->orig[$attr_name]=='') $return[$this->base['dn']]['add'][$attr_name] = $this->cn;
if ($this->$attr_name!='' && $this->orig[$attr_name]!='') $return[$this->base['dn']]['modify'][$attr_name] = $this->cn;
if ($this->$attr_name=='' && $this->orig[$attr_name]!='') $return[$this->base['dn']]['remove'][$attr_name] = $this->cn;
// *** fixme, encode as unicode
if (count($this->attributes[$attr_name])!=0 && count($this->orig[$attr_name])==0) $return[$this->base['dn']]['add'][$attr_name] = $this->attributes[$attr_name];
if (count($this->attributes[$attr_name])!=0 && count($this->orig[$attr_name])!=0) {
// We have to check every single attribute
// Get attributes which should be added
$attributes = ldap_delete($this->orig[$attr_name], $this->attributes[$attr_name]);
// Encode as unicode
for ($i=0; $i<count($attributes); $i++) $attributes[$i] = utf8_encode ($attributes[$i]);
if (count($attributes)!=0) $return[$this->base['dn']]['add'][$attr_name] = $attributes;
// Get attributes which should be removed
$attributes = ldap_delete($this->attributes[$attr_name], $this->orig[$attr_name]);
// Encode as unicode
for ($i=0; $i<count($attributes); $i++) $attributes[$i] = utf8_encode ($attributes[$i]);
if (count($attributes)!=0) $return[$this->base['dn']]['remove'][$attr_name] = $attributes;
}
if (count($this->attributes[$attr_name])==0 && count($this->orig[$attr_name])!=0) $return[$this->base['dn']]['remove'][$attr_name] = $this->orig[$attr_name];
}
// Set unix password
if ($this->orig['enc_userPassword']=='') {
if (count($this->orig['userPassword'])==0) {
// New user or no old password set
if ($this->userPassword_no) $return[$this->base['dn']]['modify']['userPassword'] = pwd_hash ('', !$this->userPassword_lock);
else $return[$this->base['dn']]['modify']['userPassword'] = pwd_hash ($this->userPassword(), !$this->userPassword_lock);
if ($this->userPassword_no) {
$return[$this->base['dn']]['add']['userPassword'][0] = pwd_hash ('', !$this->userPassword_lock);
}
else $return[$this->base['dn']]['add']['userPassword'][0] = utf8_encode(pwd_hash ($this->userPassword(), !$this->userPassword_lock));
}
else {
if ($this->userPassword()!='' || $this->userPassword_no) {
// Write new password
if ($this->userPassword_no) $return[$this->base['dn']]['modify']['userPassword'] = pwd_hash ('', !$this->userPassword_lock);
else $return[$this->base['dn']]['modify']['userPassword'] = pwd_hash ($this->userPassword(), !$this->userPassword_lock);
$return[$this->base['dn']]['remove']['userPassword'] = utf8_encode($this->orig['userPassword']);
if ($this->userPassword_no) $return[$this->base['dn']]['modify']['userPassword'][0] = pwd_hash ('', !$this->userPassword_lock);
else $return[$this->base['dn']]['modify']['userPassword'][0] = utf8_encode(pwd_hash ($this->userPassword(), !$this->userPassword_lock));
}
else { // No new password but old password
// (un)lock password
if ($this->userPassword_lock == pwd_is_enabled($this->orig['enc_userPassword'])) {
if ($this->userPassword_lock == pwd_is_enabled($this->orig['userPassword'])) {
// Split old password hash in {CRYPT} and password-hash
$i = 0;
while ($this->orig['enc_userPassword']{$i} != '}') $i++;
$passwd = substr($this->orig['enc_userPassword'], $i+1 );
$crypt = substr($this->orig['enc_userPassword'], 0, $i+1 );
while ($this->orig['userPassword']{$i} != '}') $i++;
$passwd = substr($this->orig['userPassword'], $i+1 );
$crypt = substr($this->orig['userPassword'], 0, $i+1 );
// remove trailing ! from password hash
if ($passwd{0} == '!') $passwd = substr($passwd, 1);
// Write new password
if ($this->userPassword_lock) $return[$this->base['dn']]['modify']['userPassword'] = "$crypt!$passwd";
else $return[$this->base['dn']]['modify']['userPassword'] = "$crypt$passwd";
$return[$this->base['dn']]['remove']['userPassword'] = utf8_encode($this->orig['userPassword']);
if ($this->userPassword_lock) $return[$this->base['dn']]['modify']['userPassword'][0] = utf8_encode("$crypt!$passwd");
else $return[$this->base['dn']]['modify']['userPassword'][0] = utf8_encode("$crypt$passwd");
}
}
}
}
/* This function returns all ldap attributes
* which are part of posixAccount and returns
* which are part of inetOrgPerson and returns
* also their values.
*/
function get_attributes() {
if ($userPassword_no) $return['userPassword'] = '';
else $return['userPassword'] = $this->userPassword();
$return['cn'] = $this->cn;
$return['uid'] = $this->uid;
$return['uidNumber'] = $this->uidNumber;
$return['gidNumber'] = $this->gidNumber;
$return['homeDirectory'] = $this->homeDirectory;
$return['loginShell'] = $this->loginShell;
$return['gecos'] = $this->gecos;
$return['description'] = $this->description;
// Not really ldap attributes but return values may be required
$return['groups'] = $this->groups;
if ($userPassword_lock) $return['userPasswordLocked'] = true;
else $return['userPasswordLocked'] = false;
$return = $this->attributes;
$return['userPassword'] = $this->userPassword();
return $return;
}
@ -312,141 +390,103 @@ class inetOrgPerson {
* It will output a complete html-table
*/
function display_html_attributes() {
$groups = findgroups(); // list of all groupnames
$shelllist = getshells(); // list of all valid shells
echo "<table border=0 width=\"100%\">\n<tr>\n";
echo '<td>' . _('Username') . "*</td>\n";
echo "<td><input name=\"form_posixAccount_uid\" type=\"text\" size=\"20\" maxlength=\"20\" value=\"$this->uid\"></td>\n";
echo "<td><input name=\"form_inetOrgPerson_uid\" type=\"text\" size=\"20\" maxlength=\"20\" value=\"".$this->attributes['uid'][0]."\"></td>\n";
echo "<td><a href=\"../help.php?HelpNumber=400\" target=\"lamhelp\">" . _('Help') . "</a></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>" . _('UID number') . "</td>\n";
echo "<td><input name=\"form_posixAccout_uidNumber\" type=\"text\" size=\"6\" maxlength=\"6\" value=\"$this->uidNumber\"></td>\n";
echo "<td><a href=\"../help.php?HelpNumber=401\" target=\"lamhelp\">" . _('Help') . "</a></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>" . _('Primary group') . "*</td>\n";
echo "<td><select name=\"form_posixAccount_group\">";
// loop trough existing groups
foreach ($groups as $group)
if (getgrnam($this->gidNumber) == $group) echo "<option selected> $group </option>\n";
else echo "<option> $group </option>\n";
echo "</select></td>\n";
echo "<td><a href=\"../help.php?HelpNumber=406\" target=\"lamhelp\">" . _('Help') . "</a></td>\n";
echo "</tr>\n";
if ($this->base['type']=='user') {
echo "<tr>\n";
echo "<td>" . _('Additional groups') . "</td>\n";
echo "<td><input name=\"form_posixAccount_addgroup\" type=\"submit\" value=\"" . _('Edit groups') . "\"></td>\n";
echo "<td><a href=\"../help.php?HelpNumber=402\" target=\"lamhelp\">" . _('Help') . "</a></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>" . _('Home directory') . "*</td>\n";
echo "<td><input name=\"form_posixAccount_homeDirectory\" type=\"text\" size=\"30\" maxlength=\"255\" value=\"$this->homeDirectory\"></td>\n";
echo "<td><a href=\"../help.php?HelpNumber=403\" target=\"lamhelp\">" . _('Help') . "</a></td>\n";
echo "</tr>\n";
}
echo "<tr>\n";
echo "<td>" . _('Gecos') . "</td>\n";
echo "<td><input name=\"form_posixAccount_gecos\" type=\"text\" size=\"30\" maxlength=\"255\" value=\"$this->gecos\"></td>\n";
echo "<td><a href=\"../help.php?HelpNumber=404\" target=\"lamhelp\">" . _('Help') . "</a></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>" . _('Description') . "</td>\n";
echo "<td><input name=\"form_posixAccount_description\" type=\"text\" size=\"30\" maxlength=\"255\" value=\"$this->description\"></td>\n";
echo "<td><input name=\"form_inetOrgPerson_description\" type=\"text\" size=\"30\" maxlength=\"255\" value=\"".$this->attributes['description'][0]."\"></td>\n";
echo "<td><a href=\"../help.php?HelpNumber=404\" target=\"lamhelp\">" . _('Help') . "</a></td>\n";
echo "</tr>\n";
if ($this->base['type']=='user') {
if (count($shelllist)!=0) {
echo "<tr>\n";
echo "<td>" . _('Login shell') . "*</td>\n";
echo "<td><select name=\"form_posixAccount_loginShell\">";
// loop through shells
foreach ($shelllist as $shell)
if ($this->loginShell==trim($shell)) echo "<option selected> $shell </option>\n";
else echo "<option> $shell </option>\n";
echo "</select></td>\n";
echo "<td><a href=\"../help.php?HelpNumber=405\" target=\"lamhelp\">" . _('Help') . "</a></td>\n";
echo "</tr>\n";
}
echo "<tr>\n";
echo "<td>" . _('Password') . "</td>\n";
echo "<td><input name=\"form_posixAccount_userPassword\" type=\"password\" size=\"20\" maxlength=\"20\" value=\"$this->userPassword()\"></td>\n";
echo "<td><input name=\"form_posixAccount_genpass\" type=\"submit\" value=\"" . _('Generate password') . "\"></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>" . _('Repeat password') . "</td>\n";
echo "<td><input name=\"form_posixAccount_userPassword2\" type=\"password\" size=\"20\" maxlength=\"20\" value=\"";
if (isset($_POST['form_posixAccount_userPassword2'])) echo $_POST['form_posixAccount_userPassword2'];
else echo $this->userPassword();
echo "\"></td>\n";
echo "<td></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>" . _('Use no password') . "</td>\n";
echo "<td><input name=\"form_posixAccount_userPassword_no\" type=\"checkbox\"";
if ($this->userPassword_no) echo " checked ";
echo "></td>\n";
echo "<td><a href=\"../help.php?HelpNumber=426\" target=\"lamhelp\">" . _('Help') . "</a></td>\n";
echo "</tr>\n";
}
echo "<tr>\n";
echo "<td>" . _('Password') . "</td>\n";
echo "<td><input name=\"form_inetOrgPerson_userPassword\" type=\"password\" size=\"20\" maxlength=\"20\" value=\"".$this->userPassword()."\"></td>\n";
echo "<td><input name=\"form_inetOrgPerson_genpass\" type=\"submit\" value=\"" . _('Generate password') . "\"></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>" . _('Repeat password') . "</td>\n";
echo "<td><input name=\"form_inetOrgPerson_userPassword2\" type=\"password\" size=\"20\" maxlength=\"20\" value=\"";
if (isset($_POST['form_inetOrgPerson_userPassword2'])) echo $_POST['form_posixAccount_userPassword2'];
else echo $this->userPassword();
echo "\"></td>\n";
echo "<td></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>" . _('Use no password') . "</td>\n";
echo "<td><input name=\"form_inetOrgPerson_userPassword_no\" type=\"checkbox\"";
if ($this->userPassword_no) echo " checked ";
echo "></td>\n";
echo "<td><a href=\"../help.php?HelpNumber=426\" target=\"lamhelp\">" . _('Help') . "</a></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>" . _('Lock password') . "</td>\n";
echo "<td><input name=\"form_inetOrgPerson_userPassword_no\" type=\"checkbox\"";
if ($this->userPassword_no) echo " checked ";
echo "></td>\n";
echo "<td><a href=\"../help.php?HelpNumber=426\" target=\"lamhelp\">" . _('Help') . "</a></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>" . _('Title') . "</td>\n";
echo "<td><input name=\"form_inetOrgPerson_title\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"".$this->attributes['title'][0]."\"></td>\n";
echo "<td><a href=\"../help.php?HelpNumber=448\" target=\"lamhelp\">" . _('Help') . "</a></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>" . _('First name') . "*</td>\n" ;
echo "<td><input name=\"form_inetOrgPerson_givenName\" type=\"text\" size=\"20\" maxlength=\"20\" value=\"".$this->attributes['givenName'][0]."\"></td>\n";
echo "<td><a href=\"../help.php?HelpNumber=425\" target=\"lamhelp\">" . _('Help') . "</a></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>" . _('Last name') . "*</td>\n";
echo "<td><input name=\"form_inetOrgPerson_sn\" type=\"text\" size=\"20\" maxlength=\"50\" value=\"".$this->attributes['sn'][0]."\"></td>\n";
echo "<td><a href=\"../help.php?HelpNumber=424\" target=\"lamhelp\">" . _('Help') . "</a></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>" . _('Employee type') . "</td>\n";
echo "<td><input name=\"form_inetOrgPerson_employeeType\" type=\"text\" size=\"30\" maxlength=\"30\" value=\"".$this->attributes['employeeType'][0]."\"></td>\n";
echo "<td><a href=\"../help.php?HelpNumber=449\" target=\"lamhelp\">" . _('Help') . "</a></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>" . _('Street') . "</td>\n";
echo "<td><input name=\"form_inetOrgPerson_street\" type=\"text\" size=\"30\" maxlength=\"50\" value=\"".$this->attributes['street'][0]."\"></td>\n";
echo "<td><a href=\"../help.php?HelpNumber=450\" target=\"lamhelp\">" . _('Help') . "</a></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>" . _('Postal code') . "</td>\n";
echo "<td><input name=\"form_inetOrgPerson_postalCode\" type=\"text\" size=\"5\" maxlength=\"5\" value=\"".$this->attributes['postalCode'][0]."\"></td>\n";
echo "<td><a href=\"../help.php?HelpNumber=451\" target=\"lamhelp\">" . _('Help') . "</a></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>" . _('Postal address') . "</td>\n";
echo "<td><input name=\"form_inetOrgPerson_postalAddress\" type=\"text\" size=\"30\" maxlength=\"80\" value=\"".$this->attributes['postalAddress'][0]."\"></td>\n";
echo "<td><a href=\"../help.php?HelpNumber=452\" target=\"lamhelp\">" . _('Help') . "</a></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>" . _('Telephone number') . "</td>\n";
echo "<td><input name=\"form_inetOrgPerson_telephoneNumber\" type=\"text\" size=\"30\" maxlength=\"30\" value=\"".$this->attributes['telephoneNumber'][0]."\"></td>\n";
echo "<td><a href=\"../help.php?HelpNumber=453\" target=\"lamhelp\">" . _('Help') . "</a></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>" . _('Mobile number') . "</td>\n";
echo "<td><input name=\"form_inetOrgPerson_mobileTelephoneNumber\" type=\"text\" size=\"30\" maxlength=\"30\" value=\"".$this->attributes['mobileTelephoneNumber'][0]."\"></td>\n";
echo "<td><a href=\"../help.php?HelpNumber=454\" target=\"lamhelp\">" . _('Help') . "</a></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>" . _('Fax number') . "</td>\n";
echo "<td><input name=\"form_inetOrgPerson_facsimileTelephoneNumber\" type=\"text\" size=\"30\" maxlength=\"30\" value=\"".$this->attributes['facsimileTelephoneNumber'][0]."\"></td>\n";
echo "<td><a href=\"../help.php?HelpNumber=455\" target=\"lamhelp\">" . _('Help') . "</a></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>" . _('eMail address') . "</td>\n";
echo "<td><input name=\"form_inetOrgPerson_mail\" type=\"text\" size=\"30\" maxlength=\"80\" value=\"".$this->attributes['mail'][0]."\"></td>\n";
echo "<td><a href=\"../help.php?HelpNumber=456\" target=\"lamhelp\">" . _('Help') . "</a></td>\n";
echo "</tr>\n";
echo "</table>\n";
return 0;
}
function display_html_group() {
// load list with all groups
$dn_groups = getcache('uidNumber', 'posixGroup', 'group');
foreach ($dn_groups as $group) $groups[] = $group[0];
// sort groups
sort($groups, SORT_STRING);
// remove groups the user is member of from grouplist
$groups = array_delete($this->groups, $groups);
// *** fixme primary group mut also be removed if it has changed after setting additional groups
// Remove primary group from grouplist
$groups = array_flip($groups);
if (isset($groups[getgrnam($this->gidNumber)])) unset ($groups[getgrnam($this->gidNumber)]);
$groups = array_flip($groups);
echo "<table border=0 width=\"100%\">\n<tr>\n";
echo "<td><fieldset class=\"useredit-bright\">";
echo "<legend class=\"useredit-bright\"><b>" . _("Additional groups") . "</b></legend>\n";
echo "<table border=0 width=\"100%\">\n<tr>\n";
echo "<td valign=\"top\">";
echo "<fieldset class=\"useredit-bright\">";
echo "<legend class=\"useredit-bright\">" . _("Selected groups") . "</legend>\n";
// Show all groups the user is additional member of
if (count($this->groups)!=0) {
echo "<select name=\"form_posixAccount_removegroups[]\" class=\"useredit-bright\" size=15 multiple>\n";
for ($i=0; $i<count($this->groups); $i++)
if ($this->groups[$i]!='') echo "<option> $this->groups[$i] </option>\n";
echo "</select>\n";
}
echo "</fieldset></td>\n";
echo "<td align=\"center\" width=\"10%\"><input type=\"submit\" name=\"form_posixAccount_addgroups_button\" value=\"<=\">";
echo " ";
echo "<input type=\"submit\" name=\"form_posixAccount_removegroups_button\" value=\"=>\"><br><br>";
echo "<a href=\""."../help.php?HelpNumber=402\" target=\"lamhelp\">"._('Help')."</a></td>\n";
echo "<td valign=\"top\">\n";
echo "<fieldset class=\"useredit-bright\">";
echo "<legend class=\"useredit-bright\">" . _('Available groups') . "</legend>\n";
// show all groups expect these the user is member of
if (count($groups)!=0) {
echo "<select name=\"form_posixAccount_addgroups[]\" size=15 multiple class=\"useredit-bright\">\n";
for ($i=0; $i<count($groups); $i++)
if ($groups[$i]!='') echo "<option> $groups[$i] </option>\n";
echo "</select>\n";
}
echo "</fieldset></td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<input name=\"form_posixAccount_toattributes\" type=\"submit\" value=\""; echo _('Back'); echo "\">\n";
echo "</fieldset>\n";
echo "</td></tr></table>\n";
return 0;
}
}