allow to expire password

This commit is contained in:
Roland Gruber 2010-08-05 20:42:11 +00:00
parent 68fbc6660e
commit 03d4b9975c
1 changed files with 31 additions and 1 deletions

View File

@ -187,6 +187,10 @@ class shadowAccount extends baseModule implements passwordService {
'autoAdd' => array( 'autoAdd' => array(
"Headline" => _("Automatically add this extension"), "Headline" => _("Automatically add this extension"),
"Text" => _("This will enable the extension automatically if this profile is loaded.") "Text" => _("This will enable the extension automatically if this profile is loaded.")
),
'shadowLastChange' => array(
"Headline" => _("Last password change"),
"Text" => _("This is the date when the user changed his password. If you specify a maximum password age then you can force a password change here.")
) )
); );
// upload fields // upload fields
@ -276,6 +280,9 @@ class shadowAccount extends baseModule implements passwordService {
if ( $this->attributes['shadowMin'][0] > $this->attributes['shadowMax'][0]) $errors[] = $this->messages['shadow_cmp'][0]; if ( $this->attributes['shadowMin'][0] > $this->attributes['shadowMax'][0]) $errors[] = $this->messages['shadow_cmp'][0];
if ( !get_preg($this->attributes['shadowInactive'][0], 'digit2')) $errors[] = $this->messages['inactive'][0]; if ( !get_preg($this->attributes['shadowInactive'][0], 'digit2')) $errors[] = $this->messages['inactive'][0];
if ( !get_preg($this->attributes['shadowWarning'][0], 'digit')) $errors[] = $this->messages['shadowWarning'][0]; if ( !get_preg($this->attributes['shadowWarning'][0], 'digit')) $errors[] = $this->messages['shadowWarning'][0];
if (isset($_POST['form_subpage_shadowAccount_attributes_expirePassword']) && isset($this->attributes['shadowMax'][0]) && ($this->attributes['shadowMax'][0] != 0)) {
$this->attributes['shadowLastChange'][0] = intval(time()/3600/24) - $this->attributes['shadowMax'][0] - 1;
}
return $errors; return $errors;
} }
@ -298,24 +305,28 @@ class shadowAccount extends baseModule implements passwordService {
$pwdWarnInput->setFieldMaxLength(4); $pwdWarnInput->setFieldMaxLength(4);
$pwdWarnInput->setFieldSize(5); $pwdWarnInput->setFieldSize(5);
$return->addElement($pwdWarnInput, true); $return->addElement($pwdWarnInput, true);
$shPwdExpiration = ''; $shPwdExpiration = '';
if (isset($this->attributes['shadowInactive'][0])) $shPwdExpiration = $this->attributes['shadowInactive'][0]; if (isset($this->attributes['shadowInactive'][0])) $shPwdExpiration = $this->attributes['shadowInactive'][0];
$pwdExpInput = new htmlTableExtendedInputField(_('Password expiration'), 'shadowInactive', $shPwdExpiration, 'shadowInactive'); $pwdExpInput = new htmlTableExtendedInputField(_('Password expiration'), 'shadowInactive', $shPwdExpiration, 'shadowInactive');
$pwdExpInput->setFieldMaxLength(4); $pwdExpInput->setFieldMaxLength(4);
$pwdExpInput->setFieldSize(5); $pwdExpInput->setFieldSize(5);
$return->addElement($pwdExpInput, true); $return->addElement($pwdExpInput, true);
$shMinAge = ''; $shMinAge = '';
if (isset($this->attributes['shadowMin'][0])) $shMinAge = $this->attributes['shadowMin'][0]; if (isset($this->attributes['shadowMin'][0])) $shMinAge = $this->attributes['shadowMin'][0];
$minAgeInput = new htmlTableExtendedInputField(_('Minimum password age'), 'shadowMin', $shMinAge, 'shadowMin'); $minAgeInput = new htmlTableExtendedInputField(_('Minimum password age'), 'shadowMin', $shMinAge, 'shadowMin');
$minAgeInput->setFieldMaxLength(5); $minAgeInput->setFieldMaxLength(5);
$minAgeInput->setFieldSize(5); $minAgeInput->setFieldSize(5);
$return->addElement($minAgeInput, true); $return->addElement($minAgeInput, true);
$shMaxAge = ''; $shMaxAge = '';
if (isset($this->attributes['shadowMax'][0])) $shMaxAge = $this->attributes['shadowMax'][0]; if (isset($this->attributes['shadowMax'][0])) $shMaxAge = $this->attributes['shadowMax'][0];
$maxAgeInput = new htmlTableExtendedInputField(_('Maximum password age'), 'shadowMax', $shMaxAge, 'shadowMax'); $maxAgeInput = new htmlTableExtendedInputField(_('Maximum password age'), 'shadowMax', $shMaxAge, 'shadowMax');
$maxAgeInput->setFieldMaxLength(5); $maxAgeInput->setFieldMaxLength(5);
$maxAgeInput->setFieldSize(5); $maxAgeInput->setFieldSize(5);
$return->addElement($maxAgeInput, true); $return->addElement($maxAgeInput, true);
$expirationDate = "     -      "; $expirationDate = "     -      ";
if (isset($this->attributes['shadowExpire'][0])) { if (isset($this->attributes['shadowExpire'][0])) {
$shAccExpirationDate = $this->attributes['shadowExpire'][0]; $shAccExpirationDate = $this->attributes['shadowExpire'][0];
@ -328,6 +339,22 @@ class shadowAccount extends baseModule implements passwordService {
$expireTable->addElement(new htmlAccountPageButton('shadowAccount', 'expire', 'open', _('Change'))); $expireTable->addElement(new htmlAccountPageButton('shadowAccount', 'expire', 'open', _('Change')));
$return->addElement($expireTable); $return->addElement($expireTable);
$return->addElement(new htmlHelpLink('shadowExpire'), true); $return->addElement(new htmlHelpLink('shadowExpire'), true);
$pwdChangeDate = "     -      ";
if (isset($this->attributes['shadowLastChange'][0])) {
$shPwdChangeDate = $this->attributes['shadowLastChange'][0];
$date = getdate($shPwdChangeDate*3600*24);
$pwdChangeDate = $date['mday'] . "." . $date['mon'] . "." . $date['year'];
}
$return->addElement(new htmlOutputText(_('Last password change')));
$pwdChangeTable = new htmlTable();
$pwdChangeTable->addElement(new htmlOutputText($pwdChangeDate, false));
if (isset($this->attributes['shadowMax'][0]) && ($this->attributes['shadowMax'][0] != '')) {
$pwdChangeTable->addElement(new htmlAccountPageButton('shadowAccount', 'attributes', 'expirePassword', _('Force password change')));
}
$return->addElement($pwdChangeTable);
$return->addElement(new htmlHelpLink('shadowLastChange'), true);
$return->addElement(new htmlOutputText(''), true); $return->addElement(new htmlOutputText(''), true);
$remButton = new htmlAccountPageButton('shadowAccount', 'attributes', 'remObjectClass', _('Remove Shadow account extension')); $remButton = new htmlAccountPageButton('shadowAccount', 'attributes', 'remObjectClass', _('Remove Shadow account extension'));
$remButton->colspan = 4; $remButton->colspan = 4;
@ -401,7 +428,10 @@ class shadowAccount extends baseModule implements passwordService {
return array('shadowAccount_shadowLastChange' => array('<block><key>' . _('Last password change') . '</key><value>' . date('d. m. Y',$this->attributes['shadowLastChange'][0]*24*3600) . '</value></block>'), return array('shadowAccount_shadowLastChange' => array('<block><key>' . _('Last password change') . '</key><value>' . date('d. m. Y',$this->attributes['shadowLastChange'][0]*24*3600) . '</value></block>'),
'shadowAccount_shadowWarning' => array('<block><key>' . _('Password warning') . '</key><value>' . $this->attributes['shadowWarn'][0] . '</value><block>'), 'shadowAccount_shadowWarning' => array('<block><key>' . _('Password warning') . '</key><value>' . $this->attributes['shadowWarn'][0] . '</value><block>'),
'shadowAccount_shadowInactive' => array('<block><key>' . _('Password expiration') . '</key><value>' . $this->attributes['shadowInactive'][0] . '</value></block>'), 'shadowAccount_shadowInactive' => array('<block><key>' . _('Password expiration') . '</key><value>' . $this->attributes['shadowInactive'][0] . '</value></block>'),
'shadowAccount_shadowExpire' => array('<block><key>' . _('Account expiration date') . '</key><value>' . date('d. m. Y',$this->attributes['shadowExpire'][0]*24*3600) . '</value></block>')); 'shadowAccount_shadowExpire' => array('<block><key>' . _('Account expiration date') . '</key><value>' . date('d. m. Y',$this->attributes['shadowExpire'][0]*24*3600) . '</value></block>'),
'shadowAccount_shadowMinAge' => array('<block><key>' . _('Minimum password age') . '</key><value>' . $this->attributes['shadowMin'][0] . '</value><block>'),
'shadowAccount_shadowMaxAge' => array('<block><key>' . _('Maximum password age') . '</key><value>' . $this->attributes['shadowMax'][0] . '</value><block>'),
);
} }
/** /**