| 1 |
<?php |
| 2 |
|
| 3 |
use LAM\JOB\AccountExpirationCleanupJob; |
| 4 |
use LAM\JOB\PasswordExpirationJob; |
| 5 |
use LAM\TYPES\ConfiguredType; |
| 6 |
|
| 7 |
/* |
| 8 |
|
| 9 |
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) |
| 10 |
Copyright (C) 2003 - 2006 Tilo Lutz |
| 11 |
Copyright (C) 2007 - 2026 Roland Gruber |
| 12 |
|
| 13 |
This program is free software; you can redistribute it and/or modify |
| 14 |
it under the terms of the GNU General Public License as published by |
| 15 |
the Free Software Foundation; either version 2 of the License, or |
| 16 |
(at your option) any later version. |
| 17 |
|
| 18 |
This program is distributed in the hope that it will be useful, |
| 19 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 |
GNU General Public License for more details. |
| 22 |
|
| 23 |
You should have received a copy of the GNU General Public License |
| 24 |
along with this program; if not, write to the Free Software |
| 25 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 26 |
*/ |
| 27 |
|
| 28 |
/** |
| 29 |
* Manages Unix shadow accounts for users. |
| 30 |
* |
| 31 |
* @package modules |
| 32 |
* |
| 33 |
* @author Tilo Lutz |
| 34 |
* @author Roland Gruber |
| 35 |
* @author Michael Duergner |
| 36 |
*/ |
| 37 |
|
| 38 |
/** |
| 39 |
* Manages the object class "shadowAccount" for users. |
| 40 |
* |
| 41 |
* @package modules |
| 42 |
*/ |
| 43 |
class shadowAccount extends baseModule implements passwordService, AccountStatusProvider { |
| 44 |
|
| 45 |
/** |
| 46 |
* These attributes will be ignored by default if a new account is copied from an existing one. |
| 47 |
*/ |
| 48 |
private const ATTRIBUTES_TO_IGNORE_ON_COPY = ['shadowlastchange', 'shadowexpire']; |
| 49 |
|
| 50 |
/** |
| 51 |
* ID for expired account status. |
| 52 |
*/ |
| 53 |
private const STATUS_ACCOUNT_EXPIRED = "SHADOW_ACCOUNT_EXPIRED"; |
| 54 |
|
| 55 |
/** |
| 56 |
* ID for expired password status. |
| 57 |
*/ |
| 58 |
private const STATUS_PASSWORD_EXPIRED = "SHADOW_PASSWORD_EXPIRED"; |
| 59 |
|
| 60 |
/** |
| 61 |
* Creates a new shadowAccount object. |
| 62 |
* |
| 63 |
* @param string $scope account type (user, group, host) |
| 64 |
*/ |
| 65 |
public function __construct($scope) { |
| 66 |
// call parent constructor |
| 67 |
parent::__construct($scope); |
| 68 |
$this->autoAddObjectClasses = false; |
| 69 |
} |
| 70 |
|
| 71 |
/** |
| 72 |
* {@inheritDoc} |
| 73 |
*/ |
| 74 |
protected function load_Messages(): void { |
| 75 |
// error messages for input checks |
| 76 |
$this->messages['shadowmin'][0] = ['ERROR', _('Minimum password age'), _('Password minimum age must be are natural number.')]; |
| 77 |
$this->messages['shadowmin'][1] = ['ERROR', _('Account %s:') . ' shadowAccount_minAge', _('Password minimum age must be are natural number.')]; |
| 78 |
$this->messages['shadowmax'][0] = ['ERROR', _('Maximum password age'), _('Password maximum age must be are natural number.')]; |
| 79 |
$this->messages['shadowmax'][1] = ['ERROR', _('Account %s:') . ' shadowAccount_maxAge', _('Password maximum age must be are natural number.')]; |
| 80 |
$this->messages['inactive'][0] = ['ERROR', _('Password expiration'), _('Password expiration must be are natural number or -1.')]; |
| 81 |
$this->messages['inactive'][1] = ['ERROR', _('Account %s:') . ' shadowAccount_ignoreExpire', _('Password expiration must be are natural number or -1.')]; |
| 82 |
$this->messages['shadowwarning'][0] = ['ERROR', _('Password warning'), _('Password warning must be are natural number.')]; |
| 83 |
$this->messages['shadowwarning'][1] = ['ERROR', _('Account %s:') . ' shadowAccount_warning', _('Password warning must be are natural number.')]; |
| 84 |
$this->messages['shadow_cmp'][0] = ['ERROR', _('Maximum password age'), _('Password maximum age must be bigger than password minimum age.')]; |
| 85 |
$this->messages['shadow_cmp'][1] = ['ERROR', _('Account %s:') . ' shadowAccount_min/maxAge', _('Password maximum age must be bigger as password minimum age.')]; |
| 86 |
$this->messages['shadow_expireDate'][0] = ['ERROR', _('Account %s:') . ' shadowAccount_expireDate', _('The expiration date is invalid.')]; |
| 87 |
$this->messages['shadow_lastChange'][0] = ['ERROR', _('Account %s:') . ' shadowAccount_lastChange', _('The last password change date is invalid.')]; |
| 88 |
} |
| 89 |
|
| 90 |
/** |
| 91 |
* {@inheritDoc} |
| 92 |
*/ |
| 93 |
public function can_manage(): bool { |
| 94 |
return $this->get_scope() === 'user'; |
| 95 |
} |
| 96 |
|
| 97 |
/** |
| 98 |
* {@inheritDoc} |
| 99 |
*/ |
| 100 |
public function get_metaData(): array { |
| 101 |
$return = []; |
| 102 |
// icon |
| 103 |
$return['icon'] = 'key.svg'; |
| 104 |
// alias name |
| 105 |
$return["alias"] = _('Shadow'); |
| 106 |
// module dependencies |
| 107 |
$return['dependencies'] = ['depends' => ['posixAccount'], 'conflicts' => []]; |
| 108 |
// managed object classes |
| 109 |
$return['objectClasses'] = ['shadowAccount']; |
| 110 |
// managed attributes |
| 111 |
$return['attributes'] = ['shadowlastchange', 'shadowmin', 'shadowmax', 'shadowwarning', |
| 112 |
'shadowinactive', 'shadowexpire', 'shadowflag']; |
| 113 |
// lists for expiration date |
| 114 |
$day = ['-']; |
| 115 |
$mon = ['-']; |
| 116 |
$year = ['-']; |
| 117 |
for ($i = 1; $i <= 31; $i++) { |
| 118 |
$day[] = $i; |
| 119 |
} |
| 120 |
for ($i = 1; $i <= 12; $i++) { |
| 121 |
$mon[] = $i; |
| 122 |
} |
| 123 |
for ($i = 2003; $i <= 2030; $i++) { |
| 124 |
$year[] = $i; |
| 125 |
} |
| 126 |
$profileOptionsTable = new htmlResponsiveRow(); |
| 127 |
// auto add extension |
| 128 |
$profileOptionsTable->add(new htmlResponsiveInputCheckbox('shadowAccount_addExt', false, _('Automatically add this extension'), 'autoAdd')); |
| 129 |
// password warning |
| 130 |
$profilePwdWarning = new htmlResponsiveInputField(_('Password warning'), 'shadowAccount_shadowWarning', null, 'shadowwarning'); |
| 131 |
$profilePwdWarning->setFieldMaxLength(4); |
| 132 |
$profileOptionsTable->add($profilePwdWarning); |
| 133 |
// password expiration |
| 134 |
$profilePwdExpiration = new htmlResponsiveInputField(_('Password expiration'), 'shadowAccount_shadowInactive', null, 'shadowinactive'); |
| 135 |
$profilePwdExpiration->setFieldMaxLength(4); |
| 136 |
$profileOptionsTable->add($profilePwdExpiration); |
| 137 |
// minimum password age |
| 138 |
$profilePwdMinAge = new htmlResponsiveInputField(_('Minimum password age'), 'shadowAccount_shadowMin', null, 'shadowmin'); |
| 139 |
$profilePwdMinAge->setFieldMaxLength(5); |
| 140 |
$profileOptionsTable->add($profilePwdMinAge); |
| 141 |
// maximum password age |
| 142 |
$profilePwdMinAge = new htmlResponsiveInputField(_('Maximum password age'), 'shadowAccount_shadowMax', null, 'shadowmax'); |
| 143 |
$profilePwdMinAge->setFieldMaxLength(5); |
| 144 |
$profileOptionsTable->add($profilePwdMinAge); |
| 145 |
// expiration date |
| 146 |
$profileOptionsTable->addLabel(new htmlOutputText(_('Account expiration date'))); |
| 147 |
$profileOptionsExpire = new htmlResponsiveRow(); |
| 148 |
$profileOptionsExpire->add(new htmlSelect('shadowAccount_shadowExpire_day', $day, ['-']), 2, 2, 2, 'padding-right05'); |
| 149 |
$profileOptionsExpire->add(new htmlSelect('shadowAccount_shadowExpire_mon', $mon, ['-']), 2, 2, 2, 'padding-left-right05'); |
| 150 |
$profileOptionsExpire->add(new htmlSelect('shadowAccount_shadowExpire_yea', $year, ['-']), 6, 6, 6, 'padding-left-right05'); |
| 151 |
$profileOptionsExpire->add(new htmlHelpLink('shadowexpire'), 2, 2, 2, 'padding-left-right05'); |
| 152 |
$profileOptionsTable->addField($profileOptionsExpire); |
| 153 |
$return['profile_options'] = $profileOptionsTable; |
| 154 |
// profile checks |
| 155 |
$return['profile_checks']['shadowAccount_shadowMin'] = [ |
| 156 |
'type' => 'ext_preg', |
| 157 |
'regex' => 'digit', |
| 158 |
'error_message' => $this->messages['shadowmin'][0]]; |
| 159 |
$return['profile_checks']['shadowAccount_shadowMax'] = [ |
| 160 |
'type' => 'ext_preg', |
| 161 |
'regex' => 'digit', |
| 162 |
'error_message' => $this->messages['shadowmax'][0]]; |
| 163 |
$return['profile_checks']['shadowAccount_cmp'] = [ |
| 164 |
'type' => 'int_greater', |
| 165 |
'cmp_name1' => 'shadowAccount_shadowMax', |
| 166 |
'cmp_name2' => 'shadowAccount_shadowMin', |
| 167 |
'error_message' => $this->messages['shadow_cmp'][0]]; |
| 168 |
$return['profile_checks']['shadowAccount_shadowInactive'] = [ |
| 169 |
'type' => 'ext_preg', |
| 170 |
'regex' => 'digit2', |
| 171 |
'error_message' => $this->messages['inactive'][0]]; |
| 172 |
$return['profile_checks']['shadowAccount_shadowWarning'] = [ |
| 173 |
'type' => 'ext_preg', |
| 174 |
'regex' => 'digit', |
| 175 |
'error_message' => $this->messages['shadowwarning'][0]]; |
| 176 |
// profile mappings |
| 177 |
$return['profile_mappings'] = [ |
| 178 |
'shadowAccount_shadowWarning' => 'shadowwarning', |
| 179 |
'shadowAccount_shadowInactive' => 'shadowinactive', |
| 180 |
'shadowAccount_shadowMin' => 'shadowmin', |
| 181 |
'shadowAccount_shadowMax' => 'shadowmax' |
| 182 |
]; |
| 183 |
// available PDF fields |
| 184 |
$return['PDF_fields'] = [ |
| 185 |
'shadowLastChange' => _('Last password change'), |
| 186 |
'shadowWarning' => _('Password warning'), |
| 187 |
'shadowInactive' => _('Password expiration'), |
| 188 |
'shadowExpire' => _('Account expiration date'), |
| 189 |
'shadowMinAge' => _('Minimum password age'), |
| 190 |
'shadowMaxAge' => _('Maximum password age'), |
| 191 |
]; |
| 192 |
// help Entries |
| 193 |
$return['help'] = [ |
| 194 |
'shadowwarning' => [ |
| 195 |
"Headline" => _("Password warning"), 'attr' => 'shadowWarning', |
| 196 |
"Text" => _("Days before password is to expire that user is warned of pending password expiration. If set value must be >0.") . ' ' . _("Can be left empty.") |
| 197 |
], |
| 198 |
'shadowinactive' => [ |
| 199 |
"Headline" => _("Password expiration"), 'attr' => 'shadowInactive', |
| 200 |
"Text" => _("Number of days a user can login even his password has expired. -1=always.") . ' ' . _("Can be left empty.") |
| 201 |
], |
| 202 |
'shadowmin' => [ |
| 203 |
"Headline" => _("Minimum password age"), 'attr' => 'shadowMin', |
| 204 |
"Text" => _("Number of days a user has to wait until he is allowed to change his password again. If set value must be >0.") . ' ' . _("Can be left empty.") |
| 205 |
], |
| 206 |
'shadowmax' => [ |
| 207 |
"Headline" => _("Maximum password age"), 'attr' => 'shadowMax', |
| 208 |
"Text" => _("Number of days after a user has to change his password again. If set value must be >0.") . ' ' . _("Can be left empty.") |
| 209 |
], |
| 210 |
'shadowexpire' => [ |
| 211 |
"Headline" => _("Account expiration date"), 'attr' => 'shadowExpire', |
| 212 |
"Text" => _("This is the date when the account will expire. Format: DD-MM-YYYY") |
| 213 |
], |
| 214 |
'autoAdd' => [ |
| 215 |
"Headline" => _("Automatically add this extension"), |
| 216 |
"Text" => _("This will enable the extension automatically if this profile is loaded.") |
| 217 |
], |
| 218 |
'shadowlastchange' => [ |
| 219 |
"Headline" => _("Last password change"), 'attr' => 'shadowLastChange', |
| 220 |
"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.") |
| 221 |
], |
| 222 |
'cronAddWarningPeriod' => [ |
| 223 |
"Headline" => _('Add expiration warning time'), 'attr' => 'shadowWarning', |
| 224 |
"Text" => _('This will add the warning period for password expiration on top.') |
| 225 |
] |
| 226 |
]; |
| 227 |
// upload fields |
| 228 |
$return['upload_columns'] = [ |
| 229 |
[ |
| 230 |
'name' => 'shadowAccount_warning', |
| 231 |
'description' => _('Password warning'), |
| 232 |
'help' => 'shadowwarning', |
| 233 |
'example' => '14' |
| 234 |
], |
| 235 |
[ |
| 236 |
'name' => 'shadowAccount_ignoreExpire', |
| 237 |
'description' => _('Password expiration'), |
| 238 |
'help' => 'shadowinactive', |
| 239 |
'example' => '7' |
| 240 |
], |
| 241 |
[ |
| 242 |
'name' => 'shadowAccount_minAge', |
| 243 |
'description' => _('Minimum password age'), |
| 244 |
'help' => 'shadowmin', |
| 245 |
'example' => '1' |
| 246 |
], |
| 247 |
[ |
| 248 |
'name' => 'shadowAccount_maxAge', |
| 249 |
'description' => _('Maximum password age'), |
| 250 |
'help' => 'shadowmax', |
| 251 |
'example' => '365' |
| 252 |
], |
| 253 |
[ |
| 254 |
'name' => 'shadowAccount_expireDate', |
| 255 |
'description' => _('Account expiration date'), |
| 256 |
'help' => 'shadowexpire', |
| 257 |
'example' => '17-07-2011' |
| 258 |
], |
| 259 |
[ |
| 260 |
'name' => 'shadowAccount_lastChange', |
| 261 |
'description' => _('Last password change'), |
| 262 |
'help' => 'shadowlastchange', |
| 263 |
'example' => '17-07-2011' |
| 264 |
] |
| 265 |
]; |
| 266 |
// self-service fields |
| 267 |
$return['selfServiceFieldSettings'] = [ |
| 268 |
'shadowLastChange' => _('Last password change (read-only)'), |
| 269 |
'shadowExpire' => _('Account expiration date (read-only)') |
| 270 |
]; |
| 271 |
return $return; |
| 272 |
} |
| 273 |
|
| 274 |
/** |
| 275 |
* {@inheritDoc} |
| 276 |
*/ |
| 277 |
public function loadAttributesFromAccountCopy(array $ldapAttributes, array $attributesToIgnore = []): void { |
| 278 |
parent::loadAttributesFromAccountCopy($ldapAttributes, array_merge(baseModule::ATTRIBUTES_TO_IGNORE_ON_COPY_DEFAULT, self::ATTRIBUTES_TO_IGNORE_ON_COPY)); |
| 279 |
} |
| 280 |
|
| 281 |
/** |
| 282 |
* {@inheritDoc} |
| 283 |
*/ |
| 284 |
public function save_attributes(): array { |
| 285 |
if (!in_array('shadowAccount', $this->attributes['objectClass']) && !in_array('shadowAccount', $this->orig['objectClass'])) { |
| 286 |
// skip saving if the extension was not added/modified |
| 287 |
return []; |
| 288 |
} |
| 289 |
return parent::save_attributes(); |
| 290 |
} |
| 291 |
|
| 292 |
/** |
| 293 |
* {@inheritDoc} |
| 294 |
*/ |
| 295 |
public function process_attributes(): array { |
| 296 |
if (isset($_POST['form_subpage_shadowAccount_attributes_remObjectClass'])) { |
| 297 |
$this->attributes['objectClass'] = array_delete(['shadowAccount'], $this->attributes['objectClass']); |
| 298 |
if (isset($this->attributes['shadowmin'])) { |
| 299 |
unset($this->attributes['shadowmin']); |
| 300 |
} |
| 301 |
if (isset($this->attributes['shadowmax'])) { |
| 302 |
unset($this->attributes['shadowmax']); |
| 303 |
} |
| 304 |
if (isset($this->attributes['shadowwarning'])) { |
| 305 |
unset($this->attributes['shadowwarning']); |
| 306 |
} |
| 307 |
if (isset($this->attributes['shadowinactive'])) { |
| 308 |
unset($this->attributes['shadowinactive']); |
| 309 |
} |
| 310 |
if (isset($this->attributes['shadowlastchange'])) { |
| 311 |
unset($this->attributes['shadowlastchange']); |
| 312 |
} |
| 313 |
if (isset($this->attributes['shadowexpire'])) { |
| 314 |
unset($this->attributes['shadowexpire']); |
| 315 |
} |
| 316 |
if (isset($this->attributes['shadowflag'])) { |
| 317 |
unset($this->attributes['shadowflag']); |
| 318 |
} |
| 319 |
return []; |
| 320 |
} |
| 321 |
if (!in_array('shadowAccount', $this->attributes['objectClass'])) { |
| 322 |
return []; |
| 323 |
} |
| 324 |
$errors = []; |
| 325 |
// Load attributes |
| 326 |
$this->attributes['shadowmin'][0] = $_POST['shadowmin']; |
| 327 |
$this->attributes['shadowmax'][0] = $_POST['shadowmax']; |
| 328 |
$this->attributes['shadowwarning'][0] = $_POST['shadowwarning']; |
| 329 |
$this->attributes['shadowinactive'][0] = $_POST['shadowinactive']; |
| 330 |
if (!get_preg($this->attributes['shadowmin'][0], 'digit')) { |
| 331 |
$errors[] = $this->messages['shadowmin'][0]; |
| 332 |
} |
| 333 |
if (!get_preg($this->attributes['shadowmax'][0], 'digit')) { |
| 334 |
$errors[] = $this->messages['shadowmax'][0]; |
| 335 |
} |
| 336 |
if ($this->attributes['shadowmin'][0] > $this->attributes['shadowmax'][0]) { |
| 337 |
$errors[] = $this->messages['shadow_cmp'][0]; |
| 338 |
} |
| 339 |
if (!get_preg($this->attributes['shadowinactive'][0], 'digit2')) { |
| 340 |
$errors[] = $this->messages['inactive'][0]; |
| 341 |
} |
| 342 |
if (!get_preg($this->attributes['shadowwarning'][0], 'digit')) { |
| 343 |
$errors[] = $this->messages['shadowwarning'][0]; |
| 344 |
} |
| 345 |
if (isset($_POST['form_subpage_shadowAccount_attributes_expirePassword']) && isset($this->attributes['shadowmax'][0]) && ($this->attributes['shadowmax'][0] != 0)) { |
| 346 |
$this->attributes['shadowlastchange'][0] = intval(time() / 3600 / 24) - $this->attributes['shadowmax'][0] - 1; |
| 347 |
} |
| 348 |
return $errors; |
| 349 |
} |
| 350 |
|
| 351 |
/** |
| 352 |
* {@inheritDoc} |
| 353 |
*/ |
| 354 |
public function display_html_attributes(): htmlElement|array { |
| 355 |
if (isset($_POST['form_subpage_shadowAccount_attributes_addObjectClass'])) { |
| 356 |
$this->attributes['objectClass'][] = 'shadowAccount'; |
| 357 |
} |
| 358 |
$return = new htmlResponsiveRow(); |
| 359 |
if (in_array('shadowAccount', $this->attributes['objectClass'])) { |
| 360 |
$pwdWarnInput = $this->addSimpleInputTextField($return, 'shadowwarning', _('Password warning')); |
| 361 |
$pwdWarnInput->setType('number'); |
| 362 |
|
| 363 |
$pwdExpInput = $this->addSimpleInputTextField($return, 'shadowinactive', _('Password expiration')); |
| 364 |
$pwdExpInput->setType('number'); |
| 365 |
|
| 366 |
$minAgeInput = $this->addSimpleInputTextField($return, 'shadowmin', _('Minimum password age')); |
| 367 |
$minAgeInput->setType('number'); |
| 368 |
|
| 369 |
$maxAgeInput = $this->addSimpleInputTextField($return, 'shadowmax', _('Maximum password age')); |
| 370 |
$maxAgeInput->setType('number'); |
| 371 |
|
| 372 |
$expirationDate = " - "; |
| 373 |
if (isset($this->attributes['shadowexpire'][0])) { |
| 374 |
$shAccExpirationDate = (int) $this->attributes['shadowexpire'][0]; |
| 375 |
$date = new DateTime('@' . $shAccExpirationDate * 3600 * 24, new DateTimeZone('UTC')); |
| 376 |
$expirationDate = $date->format('d.m.Y'); |
| 377 |
} |
| 378 |
$return->addLabel(new htmlOutputText(_('Account expiration date'))); |
| 379 |
$expireTable = new htmlGroup(); |
| 380 |
$expireTable->addElement(new htmlOutputText($expirationDate, false)); |
| 381 |
$expireTable->addElement(new htmlAccountPageButton('shadowAccount', 'expire', 'open', 'edit-document.svg', true, _('Change'))); |
| 382 |
$expireTable->addElement(new htmlHelpLink('shadowexpire')); |
| 383 |
$return->addField($expireTable); |
| 384 |
|
| 385 |
$pwdChangeDate = " - "; |
| 386 |
if (isset($this->attributes['shadowlastchange'][0])) { |
| 387 |
$shPwdChangeDate = (int) $this->attributes['shadowlastchange'][0]; |
| 388 |
$date = new DateTime('@' . $shPwdChangeDate * 3600 * 24, new DateTimeZone('UTC')); |
| 389 |
$pwdChangeDate = $date->format('d.m.Y'); |
| 390 |
} |
| 391 |
$return->addLabel(new htmlOutputText(_('Last password change'))); |
| 392 |
$pwdChangeTable = new htmlGroup(); |
| 393 |
$pwdChangeTable->addElement(new htmlOutputText($pwdChangeDate, false)); |
| 394 |
$pwdChangeTable->addElement(new htmlAccountPageButton('shadowAccount', 'pwdChange', 'open', 'edit-document.svg', true, _('Change'))); |
| 395 |
if (isset($this->attributes['shadowmax'][0]) && ($this->attributes['shadowmax'][0] != '')) { |
| 396 |
$pwdChangeTable->addElement(new htmlAccountPageButton('shadowAccount', 'attributes', 'expirePassword', _('Force password change'))); |
| 397 |
} |
| 398 |
$pwdChangeTable->addElement(new htmlHelpLink('shadowlastchange')); |
| 399 |
$return->addField($pwdChangeTable); |
| 400 |
|
| 401 |
$return->addVerticalSpacer('2rem'); |
| 402 |
$remButton = new htmlAccountPageButton('shadowAccount', 'attributes', 'remObjectClass', _('Remove Shadow account extension')); |
| 403 |
$remButton->setCSSClasses(['lam-danger']); |
| 404 |
$return->add($remButton, 12, 12, 12, 'text-center'); |
| 405 |
} |
| 406 |
else { |
| 407 |
$return->add(new htmlAccountPageButton('shadowAccount', 'attributes', 'addObjectClass', _('Add Shadow account extension'))); |
| 408 |
} |
| 409 |
return $return; |
| 410 |
} |
| 411 |
|
| 412 |
/** |
| 413 |
* Processes user input of the expiration page. |
| 414 |
* It checks if all input values are correct and updates the associated LDAP attributes. |
| 415 |
* |
| 416 |
* @return array<string|string[]>[] list of info/error messages |
| 417 |
*/ |
| 418 |
public function process_expire(): array { |
| 419 |
$errors = []; |
| 420 |
// set expiration date |
| 421 |
if (isset($_POST['form_subpage_shadowAccount_attributes_change']) && !empty($_POST['shadowexpire'])) { |
| 422 |
$date = DateTime::createFromFormat('d.m.Y', $_POST['shadowexpire'], new DateTimeZone('UTC')); |
| 423 |
$this->attributes['shadowexpire'][0] = intval($date->format('U') / 3600 / 24); |
| 424 |
// sync other modules |
| 425 |
if (isset($_POST['syncSamba']) && ($_POST['syncSamba'] == 'on')) { |
| 426 |
$this->getAccountContainer()->getAccountModule('sambaSamAccount')->setExpirationDate( |
| 427 |
$_POST['shadowExpire_yea'], $_POST['shadowExpire_mon'], $_POST['shadowExpire_day']); |
| 428 |
} |
| 429 |
if (isset($_POST['syncWindows']) && ($_POST['syncWindows'] == 'on')) { |
| 430 |
$this->getAccountContainer()->getAccountModule('windowsUser')->setExpirationDate( |
| 431 |
$_POST['shadowExpire_yea'], $_POST['shadowExpire_mon'], $_POST['shadowExpire_day']); |
| 432 |
} |
| 433 |
if (isset($_POST['syncHeimdal']) && ($_POST['syncHeimdal'] == 'on')) { |
| 434 |
$this->getAccountContainer()->getAccountModule('heimdalKerberos')->setExpirationDate( |
| 435 |
$_POST['shadowExpire_yea'], $_POST['shadowExpire_mon'], $_POST['shadowExpire_day']); |
| 436 |
} |
| 437 |
if (isset($_POST['syncMIT']) && ($_POST['syncMIT'] == 'on')) { |
| 438 |
$this->getAccountContainer()->getAccountModule('mitKerberos')->setExpirationDate( |
| 439 |
$_POST['shadowExpire_yea'], $_POST['shadowExpire_mon'], $_POST['shadowExpire_day']); |
| 440 |
} |
| 441 |
if (isset($_POST['syncMITStructural']) && ($_POST['syncMITStructural'] == 'on')) { |
| 442 |
$this->getAccountContainer()->getAccountModule('mitKerberosStructural')->setExpirationDate( |
| 443 |
$_POST['shadowExpire_yea'], $_POST['shadowExpire_mon'], $_POST['shadowExpire_day']); |
| 444 |
} |
| 445 |
} |
| 446 |
// remove expiration date |
| 447 |
elseif (isset($_POST['form_subpage_shadowAccount_attributes_del']) |
| 448 |
|| (empty($_POST['shadowexpire']) && isset($this->attributes['shadowexpire']))) { |
| 449 |
unset($this->attributes['shadowexpire']); |
| 450 |
// sync other modules |
| 451 |
if (isset($_POST['syncWindows']) && ($_POST['syncWindows'] == 'on')) { |
| 452 |
$this->getAccountContainer()->getAccountModule('windowsUser')->setExpirationDate( |
| 453 |
null, null, null); |
| 454 |
} |
| 455 |
if (isset($_POST['syncSamba']) && ($_POST['syncSamba'] == 'on')) { |
| 456 |
$this->getAccountContainer()->getAccountModule('sambaSamAccount')->setExpirationDate( |
| 457 |
null, null, null); |
| 458 |
} |
| 459 |
if (isset($_POST['syncHeimdal']) && ($_POST['syncHeimdal'] == 'on')) { |
| 460 |
$this->getAccountContainer()->getAccountModule('heimdalKerberos')->setExpirationDate( |
| 461 |
null, null, null); |
| 462 |
} |
| 463 |
if (isset($_POST['syncMIT']) && ($_POST['syncMIT'] == 'on')) { |
| 464 |
$this->getAccountContainer()->getAccountModule('mitKerberos')->setExpirationDate( |
| 465 |
null, null, null); |
| 466 |
} |
| 467 |
if (isset($_POST['syncMITStructural']) && ($_POST['syncMITStructural'] == 'on')) { |
| 468 |
$this->getAccountContainer()->getAccountModule('mitKerberosStructural')->setExpirationDate( |
| 469 |
null, null, null); |
| 470 |
} |
| 471 |
} |
| 472 |
return $errors; |
| 473 |
} |
| 474 |
|
| 475 |
/** |
| 476 |
* This function will create the meta HTML code to show a page with the expiration date. |
| 477 |
* |
| 478 |
* @return htmlResponsiveRow meta HTML code |
| 479 |
*/ |
| 480 |
public function display_html_expire(): htmlResponsiveRow { |
| 481 |
$return = new htmlResponsiveRow(); |
| 482 |
$shAccExpirationDate = time() / (3600 * 24) + 365; |
| 483 |
if (isset($this->attributes['shadowexpire'][0])) { |
| 484 |
$shAccExpirationDate = $this->attributes['shadowexpire'][0]; |
| 485 |
} |
| 486 |
$date = new DateTime('@' . $shAccExpirationDate * 3600 * 24, new DateTimeZone('UTC')); |
| 487 |
$dateField = new htmlResponsiveInputField(_('Account expiration date'), 'shadowexpire', $date->format('d.m.Y'), 'shadowexpire'); |
| 488 |
$dateField->showCalendar('d.m.Y'); |
| 489 |
$return->add($dateField); |
| 490 |
if ($this->getAccountContainer()->getAccountModule('sambaSamAccount') != null) { |
| 491 |
$return->add(new htmlResponsiveInputCheckbox('syncSamba', false, _('Set also for Samba 3'))); |
| 492 |
} |
| 493 |
if ($this->getAccountContainer()->getAccountModule('windowsUser') != null) { |
| 494 |
$return->add(new htmlResponsiveInputCheckbox('syncWindows', false, _('Set also for Windows'))); |
| 495 |
} |
| 496 |
if ($this->getAccountContainer()->getAccountModule('heimdalKerberos') != null) { |
| 497 |
$return->add(new htmlResponsiveInputCheckbox('syncHeimdal', false, _('Set also for Kerberos'))); |
| 498 |
} |
| 499 |
if ($this->getAccountContainer()->getAccountModule('mitKerberos') != null) { |
| 500 |
$return->add(new htmlResponsiveInputCheckbox('syncMIT', false, _('Set also for Kerberos'))); |
| 501 |
} |
| 502 |
if ($this->getAccountContainer()->getAccountModule('mitKerberosStructural') != null) { |
| 503 |
$return->add(new htmlResponsiveInputCheckbox('syncMITStructural', false, _('Set also for Kerberos'))); |
| 504 |
} |
| 505 |
$return->addVerticalSpacer('2rem'); |
| 506 |
$buttonTable = new htmlGroup(); |
| 507 |
$buttonTable->addElement(new htmlAccountPageButton('shadowAccount', 'attributes', 'change', _('Change'))); |
| 508 |
if (isset($this->attributes['shadowexpire'][0])) { |
| 509 |
$buttonTable->addElement(new htmlSpacer('0.5rem', null)); |
| 510 |
$buttonTable->addElement(new htmlAccountPageButton('shadowAccount', 'attributes', 'del', _('Remove'))); |
| 511 |
} |
| 512 |
$buttonTable->addElement(new htmlSpacer('0.5rem', null)); |
| 513 |
$buttonTable->addElement(new htmlAccountPageButton('shadowAccount', 'attributes', 'back', _('Cancel'))); |
| 514 |
$return->add($buttonTable, 12, 12, 12, 'text-center'); |
| 515 |
return $return; |
| 516 |
} |
| 517 |
|
| 518 |
/** |
| 519 |
* Processes user input of the last password change page. |
| 520 |
* It checks if all input values are correct and updates the associated LDAP attributes. |
| 521 |
* |
| 522 |
* @return array<string|string[]>[] list of info/error messages |
| 523 |
*/ |
| 524 |
public function process_pwdChange(): array { |
| 525 |
$errors = []; |
| 526 |
// set last change date |
| 527 |
if (isset($_POST['form_subpage_shadowAccount_attributes_changePwdChange']) && !empty($_POST['shadowlastchange'])) { |
| 528 |
$date = DateTime::createFromFormat('d.m.Y', $_POST['shadowlastchange'], new DateTimeZone('UTC')); |
| 529 |
$this->attributes['shadowlastchange'][0] = intval($date->format('U') / 3600 / 24); |
| 530 |
} |
| 531 |
// remove last change date |
| 532 |
elseif (isset($_POST['form_subpage_shadowAccount_attributes_delPwdChange']) |
| 533 |
|| (empty($_POST['shadowlastchange']) && isset($this->attributes['shadowlastchange']))) { |
| 534 |
unset($this->attributes['shadowlastchange']); |
| 535 |
} |
| 536 |
return $errors; |
| 537 |
} |
| 538 |
|
| 539 |
/** |
| 540 |
* This function will create the meta HTML code to show a page with the password change date. |
| 541 |
* |
| 542 |
* @return htmlResponsiveRow meta HTML code |
| 543 |
*/ |
| 544 |
public function display_html_pwdChange(): htmlResponsiveRow { |
| 545 |
$return = new htmlResponsiveRow(); |
| 546 |
$shLastChange = time() / (3600 * 24); |
| 547 |
if (isset($this->attributes['shadowlastchange'][0])) { |
| 548 |
$shLastChange = $this->attributes['shadowlastchange'][0]; |
| 549 |
} |
| 550 |
$date = new DateTime('@' . $shLastChange * 3600 * 24, new DateTimeZone('UTC')); |
| 551 |
$dateField = new htmlResponsiveInputField(_('Last password change'), 'shadowlastchange', $date->format('d.m.Y'), 'shadowlastchange'); |
| 552 |
$dateField->showCalendar('d.m.Y'); |
| 553 |
$return->add($dateField); |
| 554 |
$return->addVerticalSpacer('2rem'); |
| 555 |
$buttonTable = new htmlGroup(); |
| 556 |
$buttonTable->addElement(new htmlAccountPageButton('shadowAccount', 'attributes', 'changePwdChange', _('Change'))); |
| 557 |
if (isset($this->attributes['shadowlastchange'][0])) { |
| 558 |
$buttonTable->addElement(new htmlSpacer('0.5rem', null)); |
| 559 |
$buttonTable->addElement(new htmlAccountPageButton('shadowAccount', 'attributes', 'delPwdChange', _('Remove'))); |
| 560 |
} |
| 561 |
$buttonTable->addElement(new htmlSpacer('0.5rem', null)); |
| 562 |
$buttonTable->addElement(new htmlAccountPageButton('shadowAccount', 'attributes', 'back', _('Cancel'))); |
| 563 |
$return->add($buttonTable, 12, 12, 12, 'text-center'); |
| 564 |
return $return; |
| 565 |
} |
| 566 |
|
| 567 |
/** |
| 568 |
* {@inheritDoc} |
| 569 |
*/ |
| 570 |
public function get_pdfEntries(array $pdfKeys, string $typeId): array { |
| 571 |
$timeZone = getTimeZone(); |
| 572 |
$shadowLastChange = ''; |
| 573 |
if (!empty($this->attributes['shadowlastchange'][0])) { |
| 574 |
$time = new DateTime('@' . ((int) $this->attributes['shadowlastchange'][0]) * 24 * 3600, $timeZone); |
| 575 |
$shadowLastChange = $time->format('d.m.Y'); |
| 576 |
} |
| 577 |
$shadowExpire = ''; |
| 578 |
if (!empty($this->attributes['shadowexpire'][0])) { |
| 579 |
$time = new DateTime('@' . ((int) $this->attributes['shadowexpire'][0]) * 24 * 3600); |
| 580 |
$shadowExpire = $time->format('d.m.Y'); |
| 581 |
} |
| 582 |
$return = []; |
| 583 |
$this->addPDFKeyValue($return, 'shadowLastChange', _('Last password change'), $shadowLastChange); |
| 584 |
$this->addPDFKeyValue($return, 'shadowExpire', _('Account expiration date'), $shadowExpire); |
| 585 |
$this->addSimplePDFField($return, 'shadowWarning', _('Password warning')); |
| 586 |
$this->addSimplePDFField($return, 'shadowInactive', _('Password expiration')); |
| 587 |
$this->addSimplePDFField($return, 'shadowMinAge', _('Minimum password age'), 'shadowmin'); |
| 588 |
$this->addSimplePDFField($return, 'shadowMaxAge', _('Maximum password age'), 'shadowmax'); |
| 589 |
return $return; |
| 590 |
} |
| 591 |
|
| 592 |
/** |
| 593 |
* {@inheritDoc} |
| 594 |
*/ |
| 595 |
public function build_uploadAccounts(array $rawAccounts, array $ids, array &$partialAccounts, array $selectedModules, ConfiguredType &$type): array { |
| 596 |
$messages = []; |
| 597 |
for ($i = 0; $i < count($rawAccounts); $i++) { |
| 598 |
// add object class |
| 599 |
if (!in_array("shadowAccount", $partialAccounts[$i]['objectClass'])) { |
| 600 |
$partialAccounts[$i]['objectClass'][] = "shadowAccount"; |
| 601 |
} |
| 602 |
// password warning |
| 603 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'shadowAccount_warning', 'shadowwarning', |
| 604 |
'digit', $this->messages['shadowwarning'][1], $messages); |
| 605 |
// password expire ignoration |
| 606 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'shadowAccount_ignoreExpire', 'shadowinactive', |
| 607 |
'digit2', $this->messages['inactive'][1], $messages); |
| 608 |
// password minAge |
| 609 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'shadowAccount_minAge', 'shadowmin', |
| 610 |
'digit', $this->messages['shadowmin'][1], $messages); |
| 611 |
// password maxAge |
| 612 |
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'shadowAccount_maxAge', 'shadowmax', |
| 613 |
'digit', $this->messages['shadowmax'][1], $messages); |
| 614 |
// minAge <= maxAge |
| 615 |
if ((($rawAccounts[$i][$ids['shadowAccount_minAge']] != '') || ($rawAccounts[$i][$ids['shadowAccount_maxAge']] != '')) && // if at least one is set |
| 616 |
(($rawAccounts[$i][$ids['shadowAccount_minAge']] == '') || ($rawAccounts[$i][$ids['shadowAccount_maxAge']] == '') || // and one is not set |
| 617 |
($rawAccounts[$i][$ids['shadowAccount_minAge']] > $rawAccounts[$i][$ids['shadowAccount_maxAge']]))) { // or minAge > maxAge |
| 618 |
$errMsg = $this->messages['shadow_cmp'][1]; |
| 619 |
$errMsg[] = [$i]; |
| 620 |
$messages[] = $errMsg; |
| 621 |
} |
| 622 |
// expiration date |
| 623 |
if ($rawAccounts[$i][$ids['shadowAccount_expireDate']] != '') { |
| 624 |
if (get_preg($rawAccounts[$i][$ids['shadowAccount_expireDate']], 'date')) { |
| 625 |
$parts = explode('-', $rawAccounts[$i][$ids['shadowAccount_expireDate']]); |
| 626 |
$date = DateTime::createFromFormat('j.n.Y', $parts[0] . '.' . $parts[1] . '.' . $parts[2], new DateTimeZone('UTC')); |
| 627 |
$partialAccounts[$i]['shadowexpire'][] = intval($date->format('U') / 3600 / 24); |
| 628 |
} |
| 629 |
else { |
| 630 |
$errMsg = $this->messages['shadow_expireDate'][0]; |
| 631 |
$errMsg[] = [$i]; |
| 632 |
$messages[] = $errMsg; |
| 633 |
} |
| 634 |
} |
| 635 |
// shadow last change |
| 636 |
if ($rawAccounts[$i][$ids['shadowAccount_lastChange']] != '') { |
| 637 |
if (get_preg($rawAccounts[$i][$ids['shadowAccount_lastChange']], 'date')) { |
| 638 |
$parts = explode('-', $rawAccounts[$i][$ids['shadowAccount_lastChange']]); |
| 639 |
$date = DateTime::createFromFormat('j.n.Y', $parts[0] . '.' . $parts[1] . '.' . $parts[2], new DateTimeZone('UTC')); |
| 640 |
$partialAccounts[$i]['shadowlastchange'][] = intval($date->format('U') / 3600 / 24); |
| 641 |
} |
| 642 |
else { |
| 643 |
$errMsg = $this->messages['shadow_lastChange'][0]; |
| 644 |
$errMsg[] = [$i]; |
| 645 |
$messages[] = $errMsg; |
| 646 |
} |
| 647 |
} |
| 648 |
else { |
| 649 |
$date = new DateTime('now', new DateTimeZone('UTC')); |
| 650 |
$partialAccounts[$i]['shadowlastchange'][] = intval($date->format('U') / 3600 / 24); |
| 651 |
} |
| 652 |
} |
| 653 |
return $messages; |
| 654 |
} |
| 655 |
|
| 656 |
/** |
| 657 |
* {@inheritDoc} |
| 658 |
*/ |
| 659 |
public function load_profile(array $profile): void { |
| 660 |
// profile mappings in meta data |
| 661 |
parent::load_profile($profile); |
| 662 |
// add extension |
| 663 |
if (isset($profile['shadowAccount_addExt'][0]) |
| 664 |
&& ($profile['shadowAccount_addExt'][0] == "true") |
| 665 |
&& !in_array('shadowAccount', $this->attributes['objectClass'])) { |
| 666 |
$this->attributes['objectClass'][] = 'shadowAccount'; |
| 667 |
} |
| 668 |
// expiration date |
| 669 |
if (!empty($profile['shadowAccount_shadowExpire_day'][0])) { |
| 670 |
$day = $profile['shadowAccount_shadowExpire_day'][0]; |
| 671 |
$mon = $profile['shadowAccount_shadowExpire_mon'][0]; |
| 672 |
$year = $profile['shadowAccount_shadowExpire_yea'][0]; |
| 673 |
if (!(($day == '-') && ($mon == '-') && ($year == '-'))) { |
| 674 |
$day = ($day == '-') ? 1 : $day; |
| 675 |
$mon = ($mon == '-') ? 1 : $mon; |
| 676 |
$year = ($year == '-') ? 2030 : $year; |
| 677 |
$this->setExpirationDate($year, $mon, $day); |
| 678 |
} |
| 679 |
} |
| 680 |
} |
| 681 |
|
| 682 |
|
| 683 |
/** |
| 684 |
* {@inheritDoc} |
| 685 |
*/ |
| 686 |
public function managesPasswordAttributes(): bool { |
| 687 |
// only listen to password changes |
| 688 |
return false; |
| 689 |
} |
| 690 |
|
| 691 |
/** |
| 692 |
* {@inheritDoc} |
| 693 |
*/ |
| 694 |
public function supportsForcePasswordChange(): bool { |
| 695 |
return true; |
| 696 |
} |
| 697 |
|
| 698 |
/** |
| 699 |
* {@inheritDoc} |
| 700 |
*/ |
| 701 |
public function passwordChangeRequested(string $password, array $modules, bool $forcePasswordChange): array { |
| 702 |
// update password timestamp when Unix password was updated |
| 703 |
if (!in_array('posixAccount', $modules)) { |
| 704 |
return []; |
| 705 |
} |
| 706 |
if (in_array_ignore_case('shadowAccount', $this->attributes['objectClass'])) { |
| 707 |
$this->attributes['shadowlastchange'][0] = intval(time() / 3600 / 24); |
| 708 |
if ($forcePasswordChange && isset($this->attributes['shadowmax'][0]) && ($this->attributes['shadowmax'][0] != 0)) { |
| 709 |
$this->attributes['shadowlastchange'][0] = intval(time() / 3600 / 24) - $this->attributes['shadowmax'][0] - 1; |
| 710 |
} |
| 711 |
} |
| 712 |
return []; |
| 713 |
} |
| 714 |
|
| 715 |
/** |
| 716 |
* Sets the expiration date of this account. |
| 717 |
* If all parameters are null, the expiration date will be removed. |
| 718 |
* |
| 719 |
* @param int|null $year year (e.g. 2040) |
| 720 |
* @param int|null $month month (e.g. 8) |
| 721 |
* @param int|null $day day (e.g. 27) |
| 722 |
*/ |
| 723 |
public function setExpirationDate($year, $month, $day): void { |
| 724 |
if (($year == null) && ($month == null) && ($day == null)) { |
| 725 |
unset($this->attributes['shadowexpire']); |
| 726 |
return; |
| 727 |
} |
| 728 |
$date = DateTime::createFromFormat('j.n.Y', $day . '.' . $month . '.' . $year, new DateTimeZone('UTC')); |
| 729 |
$this->attributes['shadowexpire'][0] = intval($date->format('U') / 3600 / 24); |
| 730 |
} |
| 731 |
|
| 732 |
/** |
| 733 |
* Sets the last password change date of this account. |
| 734 |
* If all parameters are null the password change date will be removed. |
| 735 |
* |
| 736 |
* @param string|null $year year (e.g. 2040) |
| 737 |
* @param string|null $month month (e.g. 8) |
| 738 |
* @param string|null $day day (e.g. 27) |
| 739 |
*/ |
| 740 |
public function setLastChangeDate(?string $year, ?string $month, ?string $day): void { |
| 741 |
if (($year === null) && ($month === null) && ($day === null)) { |
| 742 |
unset($this->attributes['shadowlastchange']); |
| 743 |
return; |
| 744 |
} |
| 745 |
$date = DateTime::createFromFormat('j.n.Y', $day . '.' . $month . '.' . $year, new DateTimeZone('UTC')); |
| 746 |
$this->attributes['shadowlastchange'][0] = intval($date->format('U') / 3600 / 24); |
| 747 |
} |
| 748 |
|
| 749 |
/** |
| 750 |
* {@inheritDoc} |
| 751 |
*/ |
| 752 |
public function getSelfServiceOptions(array $fields, array $attributes, bool $passwordChangeOnly, array $readOnlyFields): array { |
| 753 |
$return = []; |
| 754 |
if ($passwordChangeOnly) { |
| 755 |
return $return; // no fields as long no LDAP content can be read |
| 756 |
} |
| 757 |
if (in_array('shadowLastChange', $fields)) { |
| 758 |
$shadowLastChange = ''; |
| 759 |
if (isset($attributes['shadowlastchange'][0])) { |
| 760 |
$date = new DateTime('@' . (intval($attributes['shadowlastchange'][0]) * 3600 * 24), new DateTimeZone('UTC')); |
| 761 |
$shadowLastChange = $date->format('d.m.Y'); |
| 762 |
} |
| 763 |
$row = new htmlResponsiveRow(); |
| 764 |
$row->addLabel(new htmlOutputText($this->getSelfServiceLabel('shadowLastChange', _('Last password change')))); |
| 765 |
$row->addField(new htmlOutputText($shadowLastChange)); |
| 766 |
$return['shadowLastChange'] = $row; |
| 767 |
} |
| 768 |
if (in_array('shadowExpire', $fields)) { |
| 769 |
$shadowExpire = ''; |
| 770 |
if (isset($attributes['shadowexpire'][0])) { |
| 771 |
$date = new DateTime('@' . (intval($attributes['shadowexpire'][0]) * 3600 * 24), new DateTimeZone('UTC')); |
| 772 |
$shadowExpire = $date->format('d.m.Y'); |
| 773 |
} |
| 774 |
$row = new htmlResponsiveRow(); |
| 775 |
$row->addLabel(new htmlOutputText($this->getSelfServiceLabel('shadowExpire', _('Account expiration date')))); |
| 776 |
$row->addField(new htmlOutputText($shadowExpire)); |
| 777 |
$return['shadowExpire'] = $row; |
| 778 |
} |
| 779 |
return $return; |
| 780 |
} |
| 781 |
|
| 782 |
/** |
| 783 |
* {@inheritDoc} |
| 784 |
*/ |
| 785 |
public function getSupportedJobs(LAMConfig $config): array { |
| 786 |
return [ |
| 787 |
new ShadowAccountPasswordNotifyJob(), |
| 788 |
new ShadowAccountExpirationCleanupJob(), |
| 789 |
new ShadowAccountExpirationNotifyJob() |
| 790 |
]; |
| 791 |
} |
| 792 |
|
| 793 |
/** |
| 794 |
* Returns if the given account is expired. |
| 795 |
* |
| 796 |
* @param array<string, string[]|string> $attrs LDAP attributes |
| 797 |
* @return bool expired |
| 798 |
*/ |
| 799 |
public static function isAccountExpired(array $attrs): bool { |
| 800 |
if (empty($attrs['shadowexpire'][0])) { |
| 801 |
return false; |
| 802 |
} |
| 803 |
$time = new DateTime('@' . (intval($attrs['shadowexpire'][0]) * 24 * 3600), new DateTimeZone('UTC')); |
| 804 |
$now = new DateTime('now', getTimeZone()); |
| 805 |
return ($time < $now); |
| 806 |
} |
| 807 |
|
| 808 |
/** |
| 809 |
* Returns if the given password is expired. |
| 810 |
* |
| 811 |
* @param array<string, string[]|string> $attrs LDAP attributes |
| 812 |
* @return bool expired |
| 813 |
*/ |
| 814 |
public static function isPasswordExpired(array $attrs): bool { |
| 815 |
if (empty($attrs['shadowlastchange'][0]) || empty($attrs['shadowmax'][0])) { |
| 816 |
return false; |
| 817 |
} |
| 818 |
if (($attrs['shadowlastchange'][0] < 1) || ($attrs['shadowmax'][0] < 1)) { |
| 819 |
return false; |
| 820 |
} |
| 821 |
$time = new DateTime('@' . (intval($attrs['shadowlastchange'][0]) * 24 * 3600), new DateTimeZone('UTC')); |
| 822 |
$time = $time->add(new DateInterval('P' . $attrs['shadowmax'][0] . 'D')); |
| 823 |
if (!empty($attrs['shadowinactive'][0]) && ($attrs['shadowinactive'][0] > 0)) { |
| 824 |
$time = $time->add(new DateInterval('P' . $attrs['shadowinactive'][0] . 'D')); |
| 825 |
} |
| 826 |
$now = new DateTime('now', getTimeZone()); |
| 827 |
return ($time < $now); |
| 828 |
} |
| 829 |
|
| 830 |
/** |
| 831 |
* @inheritDoc |
| 832 |
*/ |
| 833 |
public function supportsPasswordQuickChangePage(): bool { |
| 834 |
return true; |
| 835 |
} |
| 836 |
|
| 837 |
/** |
| 838 |
* @inheritDoc |
| 839 |
*/ |
| 840 |
public function addPasswordQuickChangeAccountDetails(htmlResponsiveRow $row): void { |
| 841 |
// no details |
| 842 |
} |
| 843 |
|
| 844 |
/** |
| 845 |
* @inheritDoc |
| 846 |
*/ |
| 847 |
public function getPasswordQuickChangeOptions(bool $forcePasswordChangeByDefault): array { |
| 848 |
$options = []; |
| 849 |
if (in_array_ignore_case('shadowAccount', $this->attributes['objectClass'])) { |
| 850 |
$options[] = new PasswordQuickChangeOption('forcePasswordChangeUnix', _('Force Unix password change'), $forcePasswordChangeByDefault); |
| 851 |
} |
| 852 |
return $options; |
| 853 |
} |
| 854 |
|
| 855 |
/** |
| 856 |
* @inheritDoc |
| 857 |
*/ |
| 858 |
public function getPasswordQuickChangeChanges(string $password): array { |
| 859 |
if (!in_array_ignore_case('shadowAccount', $this->attributes['objectClass'])) { |
| 860 |
return []; |
| 861 |
} |
| 862 |
$attrs = []; |
| 863 |
if (isset($this->attributes['shadowlastchange'][0]) && isset($_POST['updateUnixPwd'])) { |
| 864 |
$attrs['shadowlastchange'][0] = intval(time() / 3600 / 24); |
| 865 |
} |
| 866 |
if (isset($_POST['forcePasswordChangeUnix']) |
| 867 |
&& isset($this->attributes['shadowmax'][0]) |
| 868 |
&& ($this->attributes['shadowmax'][0] != 0)) { |
| 869 |
$attrs['shadowlastchange'][0] = intval(time() / 3600 / 24) |
| 870 |
- ((int) $this->attributes['shadowmax'][0]) - 1; |
| 871 |
} |
| 872 |
return $attrs; |
| 873 |
} |
| 874 |
|
| 875 |
/** |
| 876 |
* @inheritDoc |
| 877 |
*/ |
| 878 |
public function getPasswordQuickChangePasswordStrengthUserName(): ?string { |
| 879 |
return null; |
| 880 |
} |
| 881 |
|
| 882 |
/** |
| 883 |
* @inheritDoc |
| 884 |
*/ |
| 885 |
public function getPasswordQuickChangePasswordStrengthAttributes(): array { |
| 886 |
return []; |
| 887 |
} |
| 888 |
|
| 889 |
/** |
| 890 |
* @inheritDoc |
| 891 |
*/ |
| 892 |
public function getPasswordQuickChangeIsPasswordInHistory(string $password): bool { |
| 893 |
return false; |
| 894 |
} |
| 895 |
|
| 896 |
/** |
| 897 |
* @inheritDoc |
| 898 |
*/ |
| 899 |
public function getAccountStatusDetails(ConfiguredType $type, ?array &$attributes): array { |
| 900 |
if ($attributes === null) { |
| 901 |
$attributes = $this->attributes; |
| 902 |
} |
| 903 |
$details = []; |
| 904 |
if (self::isAccountExpired($attributes)) { |
| 905 |
$details[] = AccountStatusDetails::newPartiallyExpired(_('Shadow') . ': ' . _('Account expiration'), self::STATUS_ACCOUNT_EXPIRED); |
| 906 |
} |
| 907 |
if (self::isPasswordExpired($attributes)) { |
| 908 |
$details[] = AccountStatusDetails::newPartiallyExpired(_('Shadow') . ': ' . _('Password expiration'), self::STATUS_PASSWORD_EXPIRED); |
| 909 |
} |
| 910 |
return $details; |
| 911 |
} |
| 912 |
|
| 913 |
/** |
| 914 |
* @inheritDoc |
| 915 |
*/ |
| 916 |
public function getAccountStatusRequiredAttributes(ConfiguredType $type): array { |
| 917 |
return ['shadowexpire', 'shadowlastchange', 'shadowmax', 'shadowinactive']; |
| 918 |
} |
| 919 |
|
| 920 |
/** |
| 921 |
* @inheritDoc |
| 922 |
*/ |
| 923 |
public function getAccountStatusPossibleLockOptions(ConfiguredType $type, ?array &$attributes): array { |
| 924 |
if ($attributes === null) { |
| 925 |
$attributes = $this->attributes; |
| 926 |
} |
| 927 |
$options = []; |
| 928 |
if (!self::isAccountExpired($attributes)) { |
| 929 |
$options[] = AccountStatusDetails::newPartiallyExpired(_('Shadow') . ': ' . _('Account expiration'), self::STATUS_ACCOUNT_EXPIRED); |
| 930 |
} |
| 931 |
if (!empty($attributes['shadowmax'][0]) && !self::isPasswordExpired($attributes)) { |
| 932 |
$options[] = AccountStatusDetails::newPartiallyExpired(_('Shadow') . ': ' . _('Password expiration'), self::STATUS_PASSWORD_EXPIRED); |
| 933 |
} |
| 934 |
return $options; |
| 935 |
} |
| 936 |
|
| 937 |
/** |
| 938 |
* @inheritDoc |
| 939 |
*/ |
| 940 |
public function accountStatusPerformLock(ConfiguredType $type, ?array &$attributes, array $lockIds): void { |
| 941 |
if ($attributes === null) { |
| 942 |
$attributes = &$this->attributes; |
| 943 |
} |
| 944 |
if (in_array(self::STATUS_ACCOUNT_EXPIRED, $lockIds)) { |
| 945 |
$attributes['shadowexpire'][0] = '1'; |
| 946 |
} |
| 947 |
if (in_array(self::STATUS_PASSWORD_EXPIRED, $lockIds)) { |
| 948 |
$inactive = empty($attributes['shadowinactive'][0]) ? 0 : (int) $attributes['shadowinactive'][0]; |
| 949 |
$attributes['shadowlastchange'][0] = (string) (intval(time() / 3600 / 24) |
| 950 |
- ((int) $attributes['shadowmax'][0]) - $inactive - 1); |
| 951 |
} |
| 952 |
} |
| 953 |
|
| 954 |
/** |
| 955 |
* @inheritDoc |
| 956 |
*/ |
| 957 |
public function accountStatusPerformUnlock(ConfiguredType $type, ?array &$attributes, array $lockIds): void { |
| 958 |
if ($attributes === null) { |
| 959 |
$attributes = &$this->attributes; |
| 960 |
} |
| 961 |
if (in_array(self::STATUS_ACCOUNT_EXPIRED, $lockIds)) { |
| 962 |
unset($attributes['shadowexpire']); |
| 963 |
} |
| 964 |
if (in_array(self::STATUS_PASSWORD_EXPIRED, $lockIds)) { |
| 965 |
$attributes['shadowlastchange'][0] = (string) (time() / 3600 / 24); |
| 966 |
} |
| 967 |
} |
| 968 |
|
| 969 |
/** |
| 970 |
* @inheritDoc |
| 971 |
*/ |
| 972 |
public function getListFilterFunction(string $attributeName): ?callable { |
| 973 |
if (($attributeName === 'shadowexpire') || ($attributeName === 'shadowlastchange')) { |
| 974 |
return function(?array $values, ?string $filterValue): bool { |
| 975 |
$regex = str_replace(['*'], ['.*'], $filterValue); |
| 976 |
$regex = '/' . $regex . '/i'; |
| 977 |
if (!empty($values[0])) { |
| 978 |
$time = new DateTime('@' . $values[0] * 24 * 3600, getTimeZone()); |
| 979 |
$formattedTime = $time->format('d.m.Y'); |
| 980 |
return preg_match($regex, $formattedTime); |
| 981 |
} |
| 982 |
return false; |
| 983 |
}; |
| 984 |
} |
| 985 |
return null; |
| 986 |
} |
| 987 |
|
| 988 |
/** |
| 989 |
* @inheritDoc |
| 990 |
*/ |
| 991 |
public function getListRenderFunction(string $attributeName, ConfiguredType $type): ?callable { |
| 992 |
if (($attributeName === 'shadowexpire') || ($attributeName === 'shadowlastchange')) { |
| 993 |
return function(array $entry, string $attribute): htmlElement { |
| 994 |
if (!empty($entry[$attribute][0])) { |
| 995 |
$time = new DateTime('@' . $entry[$attribute][0] * 24 * 3600, getTimeZone()); |
| 996 |
return new htmlOutputText($time->format('d.m.Y')); |
| 997 |
} |
| 998 |
return new htmlGroup(); |
| 999 |
}; |
| 1000 |
} |
| 1001 |
return null; |
| 1002 |
} |
| 1003 |
|
| 1004 |
/** |
| 1005 |
* @inheritDoc |
| 1006 |
*/ |
| 1007 |
public function getListAttributeDescriptions(ConfiguredType $type): array { |
| 1008 |
return [ |
| 1009 |
'shadowlastchange' => _('Last password change'), |
| 1010 |
'shadowwarning' => _('Password warning'), |
| 1011 |
'shadowinactive' => _('Password expiration'), |
| 1012 |
'shadowexpire' => _('Account expiration date'), |
| 1013 |
'shadowminage' => _('Minimum password age'), |
| 1014 |
'shadowmaxage' => _('Maximum password age'), |
| 1015 |
]; |
| 1016 |
} |
| 1017 |
|
| 1018 |
} |
| 1019 |
|
| 1020 |
if (interface_exists('\LAM\JOB\Job', false)) { |
| 1021 |
|
| 1022 |
include_once __DIR__ . '/../passwordExpirationJob.inc'; |
| 1023 |
|
| 1024 |
/** |
| 1025 |
* Job to notify users about password expiration. |
| 1026 |
* |
| 1027 |
* @package jobs |
| 1028 |
*/ |
| 1029 |
class ShadowAccountPasswordNotifyJob extends PasswordExpirationJob { |
| 1030 |
|
| 1031 |
/** |
| 1032 |
* {@inheritDoc} |
| 1033 |
*/ |
| 1034 |
public function getAlias(): string { |
| 1035 |
return _('Shadow') . ': ' . _('Notify users about password expiration'); |
| 1036 |
} |
| 1037 |
|
| 1038 |
/** |
| 1039 |
* {@inheritDoc} |
| 1040 |
*/ |
| 1041 |
public function getConfigOptions(string $jobID): htmlResponsiveRow { |
| 1042 |
$container = parent::getConfigOptions($jobID); |
| 1043 |
$container->add(new htmlResponsiveInputCheckbox($this->getConfigPrefix() . '_addWarningPeriod' . $jobID, true, _('Add expiration warning time'), ['cronAddWarningPeriod', 'shadowAccount'])); |
| 1044 |
return $container; |
| 1045 |
} |
| 1046 |
|
| 1047 |
/** |
| 1048 |
* {@inheritDoc} |
| 1049 |
*/ |
| 1050 |
protected function findUsers(string $jobID, array $options): array { |
| 1051 |
// read users |
| 1052 |
$sysattrs = [$_SESSION['cfgMain']->getMailAttribute(), 'shadowlastchange', 'shadowwarning', 'shadowmax', 'userPassword']; |
| 1053 |
$attrs = $this->getAttrWildcards($jobID, $options); |
| 1054 |
$attrs = array_values(array_unique(array_merge($attrs, $sysattrs))); |
| 1055 |
return searchLDAPByFilter('(&(shadowlastchange=*)(shadowmax=*)(' . $_SESSION['cfgMain']->getMailAttribute() . '=*))', $attrs, ['user']); |
| 1056 |
} |
| 1057 |
|
| 1058 |
/** |
| 1059 |
* {@inheritDoc} |
| 1060 |
*/ |
| 1061 |
protected function checkSingleUser(string $jobID, array $options, PDO $pdo, DateTime $now, array $policyOptions, array $user, bool $isDryRun): void { |
| 1062 |
// skip if user is locked |
| 1063 |
if (!empty($user['userpassword'][0]) && !pwd_is_enabled($user['userpassword'][0])) { |
| 1064 |
$this->jobResultLog->logDebug($user['dn'] . ' is locked.'); |
| 1065 |
return; |
| 1066 |
} |
| 1067 |
if ($user['shadowmax'][0] < 1) { |
| 1068 |
$this->jobResultLog->logDebug($user['dn'] . ' does not expire.'); |
| 1069 |
return; |
| 1070 |
} |
| 1071 |
// calculate time when password expires |
| 1072 |
$lastPwdTimeUnix = intval($user['shadowlastchange'][0]) * 3600 * 24; |
| 1073 |
$lastPwdTime = new DateTime('@' . $lastPwdTimeUnix, new DateTimeZone('UTC')); |
| 1074 |
$this->jobResultLog->logDebug("Last password change on " . $lastPwdTime->format('Y-m-d')); |
| 1075 |
$numDaysToWarn = intval($options[$this->getConfigPrefix() . '_mailNotificationPeriod' . $jobID][0]); |
| 1076 |
$addPasswordWarningTime = !isset($options[$this->getConfigPrefix() . '_addWarningPeriod' . $jobID][0]) |
| 1077 |
|| ($options[$this->getConfigPrefix() . '_addWarningPeriod' . $jobID][0] === 'true'); |
| 1078 |
if ($addPasswordWarningTime && !empty($user['shadowwarning'][0]) && ($user['shadowwarning'][0] > 0)) { |
| 1079 |
$numDaysToWarn += intval($user['shadowwarning'][0]); |
| 1080 |
} |
| 1081 |
$this->jobResultLog->logDebug("Number of days before warning " . $numDaysToWarn); |
| 1082 |
$numDaysToExpire = $user['shadowmax'][0]; |
| 1083 |
$expireTime = $lastPwdTime->add(new DateInterval('P' . $numDaysToExpire . 'D')); |
| 1084 |
$this->jobResultLog->logDebug("Password expires on " . $expireTime->format('Y-m-d')); |
| 1085 |
// skip already expired accounts |
| 1086 |
if ($expireTime <= $now) { |
| 1087 |
$this->jobResultLog->logDebug($user['dn'] . ' already expired'); |
| 1088 |
return; |
| 1089 |
} |
| 1090 |
// calculate time of notification |
| 1091 |
$notifyTime = clone $expireTime; |
| 1092 |
$notifyTime->sub(new DateInterval('P' . $numDaysToWarn . 'D')); |
| 1093 |
$notifyTime->setTimeZone(getTimeZone()); |
| 1094 |
$this->jobResultLog->logDebug("Password notification on " . $notifyTime->format('Y-m-d H:i')); |
| 1095 |
// skip if notification is in the future |
| 1096 |
if ($notifyTime > $now) { |
| 1097 |
$this->jobResultLog->logDebug($user['dn'] . ' does not need notification yet.'); |
| 1098 |
return; |
| 1099 |
} |
| 1100 |
$dbLastChange = $this->getDBLastPwdChangeTime($jobID, $pdo, $user['dn']); |
| 1101 |
// skip entries where mail was already sent |
| 1102 |
if ($dbLastChange == $user['shadowlastchange'][0]) { |
| 1103 |
$this->jobResultLog->logDebug($user['dn'] . ' was already notified.'); |
| 1104 |
return; |
| 1105 |
} |
| 1106 |
if ($isDryRun) { |
| 1107 |
// no action for dry run |
| 1108 |
$this->jobResultLog->logInfo('Not sending email to ' . $user['dn'] . ' because of dry run.'); |
| 1109 |
return; |
| 1110 |
} |
| 1111 |
// send email |
| 1112 |
$success = $this->sendMail($options, $jobID, $user, $expireTime); |
| 1113 |
// update DB if mail was sent successfully |
| 1114 |
if ($success) { |
| 1115 |
$this->setDBLastPwdChangeTime($jobID, $pdo, $user['dn'], $user['shadowlastchange'][0]); |
| 1116 |
} |
| 1117 |
} |
| 1118 |
|
| 1119 |
} |
| 1120 |
|
| 1121 |
/** |
| 1122 |
* Job to notify users about account expiration. |
| 1123 |
* |
| 1124 |
* @package jobs |
| 1125 |
*/ |
| 1126 |
class ShadowAccountExpirationNotifyJob extends PasswordExpirationJob { |
| 1127 |
|
| 1128 |
/** |
| 1129 |
* {@inheritDoc} |
| 1130 |
*/ |
| 1131 |
public function getAlias(): string { |
| 1132 |
return _('Shadow') . ': ' . _('Notify users about account expiration'); |
| 1133 |
} |
| 1134 |
|
| 1135 |
/** |
| 1136 |
* {@inheritDoc} |
| 1137 |
*/ |
| 1138 |
public function getDescription(): string { |
| 1139 |
return _('This job sends out emails to inform your users that their account will expire soon.'); |
| 1140 |
} |
| 1141 |
|
| 1142 |
/** |
| 1143 |
* {@inheritDoc} |
| 1144 |
*/ |
| 1145 |
protected function findUsers(string $jobID, array $options): array { |
| 1146 |
// read users |
| 1147 |
$sysattrs = [$_SESSION['cfgMain']->getMailAttribute(), 'shadowexpire']; |
| 1148 |
$attrs = $this->getAttrWildcards($jobID, $options); |
| 1149 |
$attrs = array_values(array_unique(array_merge($attrs, $sysattrs))); |
| 1150 |
return searchLDAPByFilter('(&(shadowexpire=*)(' . $_SESSION['cfgMain']->getMailAttribute() . '=*))', $attrs, ['user']); |
| 1151 |
} |
| 1152 |
|
| 1153 |
/** |
| 1154 |
* {@inheritDoc} |
| 1155 |
*/ |
| 1156 |
protected function checkSingleUser(string $jobID, array $options, PDO $pdo, DateTime $now, array $policyOptions, array $user, bool $isDryRun): void { |
| 1157 |
$dn = $user['dn']; |
| 1158 |
$expireTimeUnix = intval($user['shadowexpire'][0]) * 3600 * 24; |
| 1159 |
$expireTime = new DateTime('@' . $expireTimeUnix, new DateTimeZone('UTC')); |
| 1160 |
$this->jobResultLog->logDebug("Expiration on " . $expireTime->format('Y-m-d')); |
| 1161 |
if ($expireTime <= $now) { |
| 1162 |
$this->jobResultLog->logDebug($dn . ' already expired'); |
| 1163 |
return; |
| 1164 |
} |
| 1165 |
$numDaysToWarn = 0; |
| 1166 |
if (!empty($options[$this->getConfigPrefix() . '_mailNotificationPeriod' . $jobID][0])) { |
| 1167 |
$numDaysToWarn = $options[$this->getConfigPrefix() . '_mailNotificationPeriod' . $jobID][0]; |
| 1168 |
} |
| 1169 |
$actionTime = clone $expireTime; |
| 1170 |
if ($numDaysToWarn != 0) { |
| 1171 |
$actionTime->sub(new DateInterval('P' . $numDaysToWarn . 'D')); |
| 1172 |
} |
| 1173 |
$actionTime->setTimeZone(getTimeZone()); |
| 1174 |
$this->jobResultLog->logDebug("Action time on " . $actionTime->format('Y-m-d')); |
| 1175 |
if ($actionTime > $now) { |
| 1176 |
$this->jobResultLog->logDebug($dn . ' does not need notification yet.'); |
| 1177 |
return; |
| 1178 |
} |
| 1179 |
$dbLastChange = $this->getDBLastPwdChangeTime($jobID, $pdo, $user['dn']); |
| 1180 |
// skip entries where mail was already sent |
| 1181 |
if ($dbLastChange == $user['shadowexpire'][0]) { |
| 1182 |
$this->jobResultLog->logDebug($dn . ' was already notified.'); |
| 1183 |
return; |
| 1184 |
} |
| 1185 |
if ($isDryRun) { |
| 1186 |
// no action for dry run |
| 1187 |
$this->jobResultLog->logInfo('Not sending email to ' . $dn . ' because of dry run.'); |
| 1188 |
return; |
| 1189 |
} |
| 1190 |
// send email |
| 1191 |
$success = $this->sendMail($options, $jobID, $user, $expireTime); |
| 1192 |
// update DB if mail was sent successfully |
| 1193 |
if ($success) { |
| 1194 |
$this->setDBLastPwdChangeTime($jobID, $pdo, $dn, $user['shadowexpire'][0]); |
| 1195 |
} |
| 1196 |
} |
| 1197 |
|
| 1198 |
} |
| 1199 |
|
| 1200 |
/** |
| 1201 |
* Job to delete or move users on account expiration. |
| 1202 |
* |
| 1203 |
* @package jobs |
| 1204 |
*/ |
| 1205 |
class ShadowAccountExpirationCleanupJob extends AccountExpirationCleanupJob { |
| 1206 |
|
| 1207 |
/** |
| 1208 |
* {@inheritDoc} |
| 1209 |
*/ |
| 1210 |
public function getAlias(): string { |
| 1211 |
return _('Shadow') . ': ' . _('Cleanup expired user accounts'); |
| 1212 |
} |
| 1213 |
|
| 1214 |
/** |
| 1215 |
* {@inheritDoc} |
| 1216 |
*/ |
| 1217 |
public function getDescription(): string { |
| 1218 |
return _('This job deletes or moves user accounts when they expire.'); |
| 1219 |
} |
| 1220 |
|
| 1221 |
/** |
| 1222 |
* {@inheritDoc} |
| 1223 |
*/ |
| 1224 |
protected function findUsers(string $jobID, array $options): array { |
| 1225 |
// read users |
| 1226 |
$attrs = ['shadowexpire']; |
| 1227 |
return searchLDAPByFilter('(shadowexpire=*)', $attrs, ['user']); |
| 1228 |
} |
| 1229 |
|
| 1230 |
/** |
| 1231 |
* {@inheritDoc} |
| 1232 |
*/ |
| 1233 |
protected function checkSingleUser(string $jobID, array $options, PDO $pdo, DateTime $now, array $policyOptions, array $user, bool $isDryRun): void { |
| 1234 |
$expireTimeUnix = intval($user['shadowexpire'][0]) * 3600 * 24; |
| 1235 |
$expireTime = new DateTime('@' . $expireTimeUnix, new DateTimeZone('UTC')); |
| 1236 |
$this->jobResultLog->logDebug("Expiration on " . $expireTime->format('Y-m-d')); |
| 1237 |
$delay = 0; |
| 1238 |
if (!empty($options[$this->getConfigPrefix() . '_delay' . $jobID][0])) { |
| 1239 |
$delay = $options[$this->getConfigPrefix() . '_delay' . $jobID][0]; |
| 1240 |
} |
| 1241 |
$actionTime = clone $expireTime; |
| 1242 |
if ($delay != 0) { |
| 1243 |
$actionTime->add(new DateInterval('P' . $delay . 'D')); |
| 1244 |
} |
| 1245 |
$actionTime->setTimeZone(getTimeZone()); |
| 1246 |
$this->jobResultLog->logDebug("Action time on " . $actionTime->format('Y-m-d')); |
| 1247 |
if ($actionTime <= $now) { |
| 1248 |
$this->performAction($jobID, $options, $user, $isDryRun); |
| 1249 |
} |
| 1250 |
} |
| 1251 |
|
| 1252 |
} |
| 1253 |
|
| 1254 |
} |