userPassword for pure inetOrgPerson accounts and error message fix

This commit is contained in:
Roland Gruber 2012-10-07 10:57:51 +00:00
parent cf66d9134f
commit 3377f79fb4
2 changed files with 25 additions and 3 deletions

View File

@ -81,6 +81,7 @@ class inetOrgPerson extends baseModule implements passwordService {
$this->messages['photo'][0] = array('ERROR', _('No file selected.')); $this->messages['photo'][0] = array('ERROR', _('No file selected.'));
$this->messages['businessCategory'][0] = array('ERROR', _('Business category'), _('Please enter a valid business category!')); $this->messages['businessCategory'][0] = array('ERROR', _('Business category'), _('Please enter a valid business category!'));
$this->messages['businessCategory'][1] = array('ERROR', _('Account %s:') . ' inetOrgPerson_businessCategory', _('Please enter a valid business category!')); $this->messages['businessCategory'][1] = array('ERROR', _('Account %s:') . ' inetOrgPerson_businessCategory', _('Please enter a valid business category!'));
$this->messages['userPassword'][0] = array('ERROR', _('Account %s:') . ' posixAccount_password', _('Password contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and #*,.;:_-+!%&/|?{[()]}=@$ !'));
} }
/** /**
@ -813,8 +814,11 @@ class inetOrgPerson extends baseModule implements passwordService {
"Headline" => _("Initials"), 'attr' => 'initials', "Headline" => _("Initials"), 'attr' => 'initials',
"Text" => _("The initials of the user's first names.") . ' ' . _('Multiple values are separated by semicolon.') "Text" => _("The initials of the user's first names.") . ' ' . _('Multiple values are separated by semicolon.')
), ),
'userPassword' => array(
"Headline" => _("Password"),
"Text" => _("Please enter the password which you want to set for this account.")
),
); );
return $return; return $return;
} }
@ -2242,6 +2246,12 @@ class inetOrgPerson extends baseModule implements passwordService {
'unique' => true, 'unique' => true,
'required' => true 'required' => true
); );
$return[] = array(
'name' => 'inetOrgPerson_userPassword',
'description' => _('Password'),
'help' => 'userPassword',
'example' => _('secret'),
);
} }
return $return; return $return;
} }
@ -2535,6 +2545,17 @@ class inetOrgPerson extends baseModule implements passwordService {
array_push($errMsg, array($i)); array_push($errMsg, array($i));
$errors[] = $errMsg; $errors[] = $errMsg;
} }
// password
if (($rawAccounts[$i][$ids['inetOrgPerson_userPassword']] != "") && (get_preg($rawAccounts[$i][$ids['inetOrgPerson_userPassword']], 'password'))) {
$partialAccounts[$i]['userPassword'] = pwd_hash($rawAccounts[$i][$ids['inetOrgPerson_userPassword']], true, $this->moduleSettings['posixAccount_pwdHash'][0]);
$partialAccounts[$i]['INFO.userPasswordClearText'] = $rawAccounts[$i][$ids['inetOrgPerson_userPassword']]; // for custom scripts etc.
}
elseif ($rawAccounts[$i][$ids['inetOrgPerson_userPassword']] != "") {
$errMsg = $this->messages['userPassword'][0];
$errMsg[2] = str_replace('%', '%%', $errMsg[2]); // double "%" because of later sprintf
array_push($errMsg, array($i));
$errors[] = $errMsg;
}
} }
} }
return $errors; return $errors;

View File

@ -92,7 +92,7 @@ class posixAccount extends baseModule implements passwordService {
$this->messages['uidNumber'][5] = array('INFO', _('UID number'), _('UID number has changed. To keep file ownership you have to run the following command as root: \'find / -uid %s -exec chown %s {} \;\'')); $this->messages['uidNumber'][5] = array('INFO', _('UID number'), _('UID number has changed. To keep file ownership you have to run the following command as root: \'find / -uid %s -exec chown %s {} \;\''));
$this->messages['userPassword'][0] = array('ERROR', _('Password'), _('Please enter the same password in both password fields.')); $this->messages['userPassword'][0] = array('ERROR', _('Password'), _('Please enter the same password in both password fields.'));
$this->messages['userPassword'][1] = array('ERROR', _('Password'), _('Password contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and #*,.;:_-+!%&/|?{[()]}=@$ !')); $this->messages['userPassword'][1] = array('ERROR', _('Password'), _('Password contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and #*,.;:_-+!%&/|?{[()]}=@$ !'));
$this->messages['userPassword'][4] = array('ERROR', _('Account %s:') . ' posixAccount_password', _('Password contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and #*,.;:_-+!%&/|?{[()]}=@$ !')); // double "%" because of sprintf $this->messages['userPassword'][4] = array('ERROR', _('Account %s:') . ' posixAccount_password', _('Password contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and #*,.;:_-+!%&/|?{[()]}=@$ !'));
$this->messages['uid'][0] = array('INFO', _('UID'), _('UID has changed. Do you want to change home directory?')); $this->messages['uid'][0] = array('INFO', _('UID'), _('UID has changed. Do you want to change home directory?'));
$this->messages['uid'][1] = array('WARN', _('User name'), _('You are using capital letters. This can cause problems because Windows is not case-sensitive.')); $this->messages['uid'][1] = array('WARN', _('User name'), _('You are using capital letters. This can cause problems because Windows is not case-sensitive.'));
$this->messages['uid'][2] = array('ERROR', _('User name'), _('User name contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and .-_ !')); $this->messages['uid'][2] = array('ERROR', _('User name'), _('User name contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and .-_ !'));
@ -1758,7 +1758,8 @@ class posixAccount extends baseModule implements passwordService {
$partialAccounts[$i]['INFO.userPasswordClearText'] = $rawAccounts[$i][$ids['posixAccount_password']]; // for custom scripts etc. $partialAccounts[$i]['INFO.userPasswordClearText'] = $rawAccounts[$i][$ids['posixAccount_password']]; // for custom scripts etc.
} }
elseif ($rawAccounts[$i][$ids['posixAccount_password']] != "") { elseif ($rawAccounts[$i][$ids['posixAccount_password']] != "") {
$errMsg = str_replace('%', '%%', $this->messages['userPassword'][4]); // double "%" because of later sprintf $errMsg = $this->messages['userPassword'][4];
$errMsg[2] = str_replace('%', '%%', $errMsg[2]); // double "%" because of later sprintf
array_push($errMsg, array($i)); array_push($errMsg, array($i));
$errors[] = $errMsg; $errors[] = $errMsg;
} }