Merge pull request #41 from LDAPAccountManager/JobResultLog

Job result log
This commit is contained in:
gruberroland 2017-10-29 16:37:40 +01:00 committed by GitHub
commit 0d0cb17ae1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 95 additions and 73 deletions

View File

@ -3,6 +3,8 @@ December 2017
- PHP 5.6 and Internet Explorer 11 or later required - PHP 5.6 and Internet Explorer 11 or later required
- Account status also shows expired accounts - Account status also shows expired accounts
- Quota: support k/m/g/t/K/M/G/T to specify values in e.g. kB - Quota: support k/m/g/t/K/M/G/T to specify values in e.g. kB
- LAM Pro:
-> Cron jobs include better logging and support dry-run
19.09.2017 6.1 19.09.2017 6.1

View File

@ -15,7 +15,7 @@
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/login.png" /> <imagedata fileref="images/login.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -30,7 +30,7 @@
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/configOverview.png" /> <imagedata fileref="images/configOverview.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -63,7 +63,7 @@
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/configGeneral7.png" /> <imagedata fileref="images/configGeneral7.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -84,15 +84,16 @@
<para id="sessionEncryption">Session encryption will encrypt sensitive <para id="sessionEncryption">Session encryption will encrypt sensitive
data like passwords in your session files. This is only available when data like passwords in your session files. This is only available when
PHP <ulink url="http://php.net/manual/en/book.openssl.php">OpenSSL</ulink> is active. This PHP <ulink
adds extra security but also costs performance. If you manage a large url="http://php.net/manual/en/book.openssl.php">OpenSSL</ulink> is
directory you might want to disable this and take other actions to active. This adds extra security but also costs performance. If you
secure your LAM server.</para> manage a large directory you might want to disable this and take other
actions to secure your LAM server.</para>
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/configGeneral1.png" /> <imagedata fileref="images/configGeneral1.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -126,7 +127,7 @@
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/configGeneral4.png" /> <imagedata fileref="images/configGeneral4.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -143,7 +144,7 @@
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/configGeneral2.png" /> <imagedata fileref="images/configGeneral2.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -168,7 +169,7 @@
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/configGeneral3.png" /> <imagedata fileref="images/configGeneral3.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -190,7 +191,7 @@
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/configGeneral6.png" /> <imagedata fileref="images/configGeneral6.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -205,7 +206,7 @@
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/configGeneral5.png" /> <imagedata fileref="images/configGeneral5.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -230,7 +231,7 @@
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/configProfiles1.png" /> <imagedata fileref="images/configProfiles1.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -275,7 +276,7 @@
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/configProfiles2.png" /> <imagedata fileref="images/configProfiles2.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -294,7 +295,7 @@
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/configProfiles3.png" /> <imagedata fileref="images/configProfiles3.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -336,7 +337,7 @@
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/configProfiles4.png" /> <imagedata fileref="images/configProfiles4.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -391,7 +392,7 @@
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/configProfiles5.png" /> <imagedata fileref="images/configProfiles5.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -426,7 +427,7 @@
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/configProfiles6.png" /> <imagedata fileref="images/configProfiles6.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -438,7 +439,7 @@
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/configProfiles10.png" /> <imagedata fileref="images/configProfiles10.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -453,7 +454,7 @@
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/configProfiles9.png" /> <imagedata fileref="images/configProfiles9.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -473,7 +474,7 @@
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/configProfiles8.png" /> <imagedata fileref="images/configProfiles8.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -512,7 +513,7 @@
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/configProfiles7.png" /> <imagedata fileref="images/configProfiles7.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -542,7 +543,7 @@
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/configProfiles11.png" /> <imagedata fileref="images/configProfiles11.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -554,7 +555,7 @@
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/configProfiles12.png" /> <imagedata fileref="images/configProfiles12.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -567,7 +568,7 @@
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/configProfiles13.png" /> <imagedata fileref="images/configProfiles13.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -583,7 +584,7 @@
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/configTypes1.png" /> <imagedata fileref="images/configTypes1.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -656,7 +657,7 @@
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/configTypes2.png" /> <imagedata fileref="images/configTypes2.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -675,7 +676,7 @@
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/configModules1.png" /> <imagedata fileref="images/configModules1.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -702,7 +703,7 @@
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/configSettings1.png" /> <imagedata fileref="images/configSettings1.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -738,7 +739,7 @@
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/jobs1.png" /> <imagedata fileref="images/jobs1.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -769,7 +770,7 @@ mysql&gt; GRANT ALL PRIVILEGES ON lam_cron.* TO 'lam_cron'@'localhost';
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/jobs3.png" /> <imagedata fileref="images/jobs3.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -786,6 +787,14 @@ mysql&gt; GRANT ALL PRIVILEGES ON lam_cron.* TO 'lam_cron'@'localhost';
configured jobs on a daily basis. The command must be run as the same configured jobs on a daily basis. The command must be run as the same
user as your webserver is running. You are free to change the starting user as your webserver is running. You are free to change the starting
time of the script or run it more often.</para> time of the script or run it more often.</para>
<para>Dry-run: You can perform a dry-run of the job. This will not
perform any actions but only print what would be done. For this please
put "--dryRun" at the end of the command. E.g.:</para>
<literallayout> /usr/share/ldap-account-manager/lib/cron.sh lam 123456789 --dryRun</literallayout>
<para/>
</section> </section>
<section> <section>
@ -803,7 +812,7 @@ mysql&gt; GRANT ALL PRIVILEGES ON lam_cron.* TO 'lam_cron'@'localhost';
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/jobs2.png" /> <imagedata fileref="images/jobs2.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -839,7 +848,7 @@ mysql&gt; GRANT ALL PRIVILEGES ON lam_cron.* TO 'lam_cron'@'localhost';
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/jobs_ppolicy1.png" /> <imagedata fileref="images/jobs_ppolicy1.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -938,7 +947,7 @@ mysql&gt; GRANT ALL PRIVILEGES ON lam_cron.* TO 'lam_cron'@'localhost';
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/jobs_389dsPasswordMail1.png" /> <imagedata fileref="images/jobs_389dsPasswordMail1.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -1040,7 +1049,7 @@ mysql&gt; GRANT ALL PRIVILEGES ON lam_cron.* TO 'lam_cron'@'localhost';
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/jobs_shadow1.png" /> <imagedata fileref="images/jobs_shadow1.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -1126,7 +1135,7 @@ mysql&gt; GRANT ALL PRIVILEGES ON lam_cron.* TO 'lam_cron'@'localhost';
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/jobs_shadow2.png" /> <imagedata fileref="images/jobs_shadow2.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -1182,7 +1191,7 @@ mysql&gt; GRANT ALL PRIVILEGES ON lam_cron.* TO 'lam_cron'@'localhost';
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/jobs_windows1.png" /> <imagedata fileref="images/jobs_windows1.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -1266,7 +1275,7 @@ mysql&gt; GRANT ALL PRIVILEGES ON lam_cron.* TO 'lam_cron'@'localhost';
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/jobs_windowsCleanup.png" /> <imagedata fileref="images/jobs_windowsCleanup.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -1314,7 +1323,7 @@ mysql&gt; GRANT ALL PRIVILEGES ON lam_cron.* TO 'lam_cron'@'localhost';
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/jobs_freeRadiusCleanup.png" /> <imagedata fileref="images/jobs_freeRadiusCleanup.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -1363,7 +1372,7 @@ mysql&gt; GRANT ALL PRIVILEGES ON lam_cron.* TO 'lam_cron'@'localhost';
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/jobs_qmailCleanup1.png" /> <imagedata fileref="images/jobs_qmailCleanup1.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -1413,7 +1422,7 @@ mysql&gt; GRANT ALL PRIVILEGES ON lam_cron.* TO 'lam_cron'@'localhost';
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/jobs4.png" /> <imagedata fileref="images/jobs4.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -1439,7 +1448,7 @@ mysql&gt; GRANT ALL PRIVILEGES ON lam_cron.* TO 'lam_cron'@'localhost';
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/LDAPStructuresSimple.png" /> <imagedata fileref="images/LDAPStructuresSimple.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -1458,7 +1467,7 @@ mysql&gt; GRANT ALL PRIVILEGES ON lam_cron.* TO 'lam_cron'@'localhost';
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/LDAPStructuresAdvanced.png" /> <imagedata fileref="images/LDAPStructuresAdvanced.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>
@ -1491,7 +1500,7 @@ mysql&gt; GRANT ALL PRIVILEGES ON lam_cron.* TO 'lam_cron'@'localhost';
<screenshot> <screenshot>
<mediaobject> <mediaobject>
<imageobject> <imageobject>
<imagedata fileref="images/LDAPStructuresMultiServer.png" /> <imagedata fileref="images/LDAPStructuresMultiServer.png"/>
</imageobject> </imageobject>
</mediaobject> </mediaobject>
</screenshot> </screenshot>

View File

@ -850,7 +850,7 @@ if (interface_exists('\LAM\JOB\Job', false)) {
*/ */
protected function checkSingleUser($jobID, $options, &$pdo, $now, $policyOptions, $user, $isDryRun) { protected function checkSingleUser($jobID, $options, &$pdo, $now, $policyOptions, $user, $isDryRun) {
$expireTime = DateTime::createFromFormat('d M Y H:i', $user['radiusexpiration'][0], new DateTimeZone('UTC')); $expireTime = DateTime::createFromFormat('d M Y H:i', $user['radiusexpiration'][0], new DateTimeZone('UTC'));
logNewMessage(LOG_DEBUG, "Expiration on " . $expireTime->format('Y-m-d')); $this->jobResultLog->logDebug("Expiration on " . $expireTime->format('Y-m-d'));
$delay = 0; $delay = 0;
if (!empty($options[$this->getConfigPrefix() . '_delay' . $jobID][0])) { if (!empty($options[$this->getConfigPrefix() . '_delay' . $jobID][0])) {
$delay = $options[$this->getConfigPrefix() . '_delay' . $jobID][0]; $delay = $options[$this->getConfigPrefix() . '_delay' . $jobID][0];
@ -860,7 +860,7 @@ if (interface_exists('\LAM\JOB\Job', false)) {
$actionTime->add(new DateInterval('P' . $delay . 'D')); $actionTime->add(new DateInterval('P' . $delay . 'D'));
} }
$actionTime->setTimeZone(getTimeZone()); $actionTime->setTimeZone(getTimeZone());
logNewMessage(LOG_DEBUG, "Action time on " . $actionTime->format('Y-m-d')); $this->jobResultLog->logDebug("Action time on " . $actionTime->format('Y-m-d'));
if ($actionTime <= $now) { if ($actionTime <= $now) {
$this->performAction($jobID, $options, $user, $isDryRun); $this->performAction($jobID, $options, $user, $isDryRun);
} }

View File

@ -862,11 +862,11 @@ if (interface_exists('\LAM\JOB\Job', false)) {
protected function checkSingleUser($jobID, $options, &$pdo, $now, $policyOptions, $user, $isDryRun) { protected function checkSingleUser($jobID, $options, &$pdo, $now, $policyOptions, $user, $isDryRun) {
// skip if user is locked // skip if user is locked
if (!empty($user['userpassword'][0]) && !pwd_is_enabled($user['userpassword'][0])) { if (!empty($user['userpassword'][0]) && !pwd_is_enabled($user['userpassword'][0])) {
logNewMessage(LOG_DEBUG, $user['dn'] . ' is locked.'); $this->jobResultLog->logDebug($user['dn'] . ' is locked.');
return; return;
} }
if ($user['shadowmax'][0] < 1) { if ($user['shadowmax'][0] < 1) {
logNewMessage(LOG_DEBUG, $user['dn'] . ' does not expire.'); $this->jobResultLog->logDebug($user['dn'] . ' does not expire.');
return; return;
} }
@ -874,39 +874,39 @@ if (interface_exists('\LAM\JOB\Job', false)) {
// calculate time when password expires // calculate time when password expires
$lastPwdTimeUnix = $user['shadowlastchange'][0] * 3600 * 24; $lastPwdTimeUnix = $user['shadowlastchange'][0] * 3600 * 24;
$lastPwdTime = new DateTime('@' . $lastPwdTimeUnix, new DateTimeZone('UTC')); $lastPwdTime = new DateTime('@' . $lastPwdTimeUnix, new DateTimeZone('UTC'));
logNewMessage(LOG_DEBUG, "Last password change on " . $lastPwdTime->format('Y-m-d')); $this->jobResultLog->logDebug("Last password change on " . $lastPwdTime->format('Y-m-d'));
$numDaysToWarn = $options[$this->getConfigPrefix() . '_mailNotificationPeriod' . $jobID][0]; $numDaysToWarn = $options[$this->getConfigPrefix() . '_mailNotificationPeriod' . $jobID][0];
if (!empty($user['shadowwarning'][0]) && ($user['shadowwarning'][0] > 0)) { if (!empty($user['shadowwarning'][0]) && ($user['shadowwarning'][0] > 0)) {
$numDaysToWarn += $user['shadowwarning'][0]; $numDaysToWarn += $user['shadowwarning'][0];
} }
logNewMessage(LOG_DEBUG, "Number of days before warning " . $numDaysToWarn); $this->jobResultLog->logDebug("Number of days before warning " . $numDaysToWarn);
$numDaysToExpire = $user['shadowmax'][0]; $numDaysToExpire = $user['shadowmax'][0];
$expireTime = $lastPwdTime->add(new DateInterval('P' . $numDaysToExpire . 'D')); $expireTime = $lastPwdTime->add(new DateInterval('P' . $numDaysToExpire . 'D'));
logNewMessage(LOG_DEBUG, "Password expires on " . $expireTime->format('Y-m-d')); $this->jobResultLog->logDebug("Password expires on " . $expireTime->format('Y-m-d'));
// skip already expired accounts // skip already expired accounts
if ($expireTime <= $now) { if ($expireTime <= $now) {
logNewMessage(LOG_DEBUG, $user['dn'] . ' already expired'); $this->jobResultLog->logDebug($user['dn'] . ' already expired');
return; return;
} }
// calculate time of notification // calculate time of notification
$notifyTime = clone $expireTime; $notifyTime = clone $expireTime;
$notifyTime->sub(new DateInterval('P' . $numDaysToWarn . 'D')); $notifyTime->sub(new DateInterval('P' . $numDaysToWarn . 'D'));
$notifyTime->setTimeZone(getTimeZone()); $notifyTime->setTimeZone(getTimeZone());
logNewMessage(LOG_DEBUG, "Password notification on " . $notifyTime->format('Y-m-d H:i')); $this->jobResultLog->logDebug("Password notification on " . $notifyTime->format('Y-m-d H:i'));
// skip if notification is in the future // skip if notification is in the future
if ($notifyTime > $now) { if ($notifyTime > $now) {
logNewMessage(LOG_DEBUG, $user['dn'] . ' does not need notification yet.'); $this->jobResultLog->logDebug($user['dn'] . ' does not need notification yet.');
return; return;
} }
$dbLastChange = $this->getDBLastPwdChangeTime($jobID, $pdo, $user['dn']); $dbLastChange = $this->getDBLastPwdChangeTime($jobID, $pdo, $user['dn']);
// skip entries where mail was already sent // skip entries where mail was already sent
if ($dbLastChange == $user['shadowlastchange'][0]) { if ($dbLastChange == $user['shadowlastchange'][0]) {
logNewMessage(LOG_DEBUG, $user['dn'] . ' was already notified.'); $this->jobResultLog->logDebug($user['dn'] . ' was already notified.');
return; return;
} }
if ($isDryRun) { if ($isDryRun) {
// no action for dry run // no action for dry run
logNewMessage(LOG_NOTICE, 'Not sending email to ' . $user['dn'] . ' because of dry run.'); $this->jobResultLog->logInfo('Not sending email to ' . $user['dn'] . ' because of dry run.');
return; return;
} }
// send email // send email
@ -972,7 +972,7 @@ if (interface_exists('\LAM\JOB\Job', false)) {
protected function checkSingleUser($jobID, $options, &$pdo, $now, $policyOptions, $user, $isDryRun) { protected function checkSingleUser($jobID, $options, &$pdo, $now, $policyOptions, $user, $isDryRun) {
$expireTimeUnix = $user['shadowexpire'][0] * 3600 * 24; $expireTimeUnix = $user['shadowexpire'][0] * 3600 * 24;
$expireTime = new DateTime('@' . $expireTimeUnix, new DateTimeZone('UTC')); $expireTime = new DateTime('@' . $expireTimeUnix, new DateTimeZone('UTC'));
logNewMessage(LOG_DEBUG, "Expiration on " . $expireTime->format('Y-m-d')); $this->jobResultLog->logDebug("Expiration on " . $expireTime->format('Y-m-d'));
$delay = 0; $delay = 0;
if (!empty($options[$this->getConfigPrefix() . '_delay' . $jobID][0])) { if (!empty($options[$this->getConfigPrefix() . '_delay' . $jobID][0])) {
$delay = $options[$this->getConfigPrefix() . '_delay' . $jobID][0]; $delay = $options[$this->getConfigPrefix() . '_delay' . $jobID][0];
@ -982,7 +982,7 @@ if (interface_exists('\LAM\JOB\Job', false)) {
$actionTime->add(new DateInterval('P' . $delay . 'D')); $actionTime->add(new DateInterval('P' . $delay . 'D'));
} }
$actionTime->setTimeZone(getTimeZone()); $actionTime->setTimeZone(getTimeZone());
logNewMessage(LOG_DEBUG, "Action time on " . $actionTime->format('Y-m-d')); $this->jobResultLog->logDebug("Action time on " . $actionTime->format('Y-m-d'));
if ($actionTime <= $now) { if ($actionTime <= $now) {
$this->performAction($jobID, $options, $user, $isDryRun); $this->performAction($jobID, $options, $user, $isDryRun);
} }

View File

@ -3484,60 +3484,60 @@ if (interface_exists('\LAM\JOB\Job', false)) {
$domainRoot = strtolower(substr($dn, stripos($dn, 'dc='))); $domainRoot = strtolower(substr($dn, stripos($dn, 'dc=')));
// skip if password does not expire at all // skip if password does not expire at all
if (windowsUser::isNeverExpiring($user)) { if (windowsUser::isNeverExpiring($user)) {
logNewMessage(LOG_DEBUG, $dn . ' does not expire.'); $this->jobResultLog->logDebug($dn . ' does not expire.');
return; return;
} }
// skip if no information about last password change // skip if no information about last password change
if (empty($user['pwdlastset'][0]) || ($user['pwdlastset'][0] < 1)) { if (empty($user['pwdlastset'][0]) || ($user['pwdlastset'][0] < 1)) {
logNewMessage(LOG_DEBUG, $dn . ' has no valid "pwdLastSet".'); $this->jobResultLog->logDebug($dn . ' has no valid "pwdLastSet".');
return; return;
} }
// skip if account itself is expired // skip if account itself is expired
if (!empty($user['accountexpires'][0])) { if (!empty($user['accountexpires'][0])) {
$accountExpiration = windowsUser::getFileTime($user['accountexpires'][0]); $accountExpiration = windowsUser::getFileTime($user['accountexpires'][0]);
if ($accountExpiration <= $now) { if ($accountExpiration <= $now) {
logNewMessage(LOG_DEBUG, $dn . ' already expired'); $this->jobResultLog->logDebug($dn . ' already expired');
return; return;
} }
} }
// skip if account is deactivated // skip if account is deactivated
if (windowsUser::isDeactivated($user)) { if (windowsUser::isDeactivated($user)) {
logNewMessage(LOG_DEBUG, $dn . ' is deactivated.'); $this->jobResultLog->logDebug($dn . ' is deactivated.');
return; return;
} }
$maxPwdAge = $policyOptions['maxpwdage'][$domainRoot]; $maxPwdAge = $policyOptions['maxpwdage'][$domainRoot];
// calculate time when password expires // calculate time when password expires
$lastPwdTime = windowsUser::getFileTime($user['pwdlastset'][0]); $lastPwdTime = windowsUser::getFileTime($user['pwdlastset'][0]);
logNewMessage(LOG_DEBUG, "Last password change on " . $lastPwdTime->format('Y-m-d')); $this->jobResultLog->logDebug("Last password change on " . $lastPwdTime->format('Y-m-d'));
$numDaysToWarn = $options[$this->getConfigPrefix() . '_mailNotificationPeriod' . $jobID][0]; $numDaysToWarn = $options[$this->getConfigPrefix() . '_mailNotificationPeriod' . $jobID][0];
logNewMessage(LOG_DEBUG, "Number of days before warning " . $numDaysToWarn); $this->jobResultLog->logDebug("Number of days before warning " . $numDaysToWarn);
// expiration date = pwdLastSet - maxpwdage // expiration date = pwdLastSet - maxpwdage
$expireTime = windowsUser::getFileTime($user['pwdlastset'][0] - $maxPwdAge); $expireTime = windowsUser::getFileTime($user['pwdlastset'][0] - $maxPwdAge);
logNewMessage(LOG_DEBUG, "Password expires on " . $expireTime->format('Y-m-d')); $this->jobResultLog->logDebug("Password expires on " . $expireTime->format('Y-m-d'));
// skip already expired accounts // skip already expired accounts
if ($expireTime <= $now) { if ($expireTime <= $now) {
logNewMessage(LOG_DEBUG, $dn . ' already expired'); $this->jobResultLog->logDebug($dn . ' already expired');
return; return;
} }
// calculate time of notification // calculate time of notification
$notifyTime = clone $expireTime; $notifyTime = clone $expireTime;
$notifyTime->sub(new DateInterval('P' . $numDaysToWarn . 'D')); $notifyTime->sub(new DateInterval('P' . $numDaysToWarn . 'D'));
$notifyTime->setTimeZone(getTimeZone()); $notifyTime->setTimeZone(getTimeZone());
logNewMessage(LOG_DEBUG, "Password notification on " . $notifyTime->format('Y-m-d H:i')); $this->jobResultLog->logDebug("Password notification on " . $notifyTime->format('Y-m-d H:i'));
// skip if notification is in the future // skip if notification is in the future
if ($notifyTime > $now) { if ($notifyTime > $now) {
logNewMessage(LOG_DEBUG, $dn . ' does not need notification yet.'); $this->jobResultLog->logDebug($dn . ' does not need notification yet.');
return; return;
} }
$dbLastChange = $this->getDBLastPwdChangeTime($jobID, $pdo, $dn); $dbLastChange = $this->getDBLastPwdChangeTime($jobID, $pdo, $dn);
// skip entries where mail was already sent // skip entries where mail was already sent
if ($dbLastChange == $user['pwdlastset'][0]) { if ($dbLastChange == $user['pwdlastset'][0]) {
logNewMessage(LOG_DEBUG, $dn . ' was already notified.'); $this->jobResultLog->logDebug($dn . ' was already notified.');
return; return;
} }
if ($isDryRun) { if ($isDryRun) {
// no action for dry run // no action for dry run
logNewMessage(LOG_NOTICE, 'Not sending email to ' . $dn . ' because of dry run.'); $this->jobResultLog->logInfo('Not sending email to ' . $dn . ' because of dry run.');
return; return;
} }
// send email // send email
@ -3605,7 +3605,7 @@ if (interface_exists('\LAM\JOB\Job', false)) {
$expireTime = new DateTime('1601-01-01', new DateTimeZone('UTC')); $expireTime = new DateTime('1601-01-01', new DateTimeZone('UTC'));
$expireTime->add(new DateInterval('PT' . $seconds . 'S')); $expireTime->add(new DateInterval('PT' . $seconds . 'S'));
$expireTime->setTimezone(getTimeZone()); $expireTime->setTimezone(getTimeZone());
logNewMessage(LOG_DEBUG, "Expiration on " . $expireTime->format('Y-m-d')); $this->jobResultLog->logDebug("Expiration on " . $expireTime->format('Y-m-d'));
$delay = 0; $delay = 0;
if (!empty($options[$this->getConfigPrefix() . '_delay' . $jobID][0])) { if (!empty($options[$this->getConfigPrefix() . '_delay' . $jobID][0])) {
$delay = $options[$this->getConfigPrefix() . '_delay' . $jobID][0]; $delay = $options[$this->getConfigPrefix() . '_delay' . $jobID][0];
@ -3615,7 +3615,7 @@ if (interface_exists('\LAM\JOB\Job', false)) {
$actionTime->add(new DateInterval('P' . $delay . 'D')); $actionTime->add(new DateInterval('P' . $delay . 'D'));
} }
$actionTime->setTimeZone(getTimeZone()); $actionTime->setTimeZone(getTimeZone());
logNewMessage(LOG_DEBUG, "Action time on " . $actionTime->format('Y-m-d')); $this->jobResultLog->logDebug("Action time on " . $actionTime->format('Y-m-d'));
if ($actionTime <= $now) { if ($actionTime <= $now) {
$this->performAction($jobID, $options, $user, $isDryRun); $this->performAction($jobID, $options, $user, $isDryRun);
} }

View File

@ -208,6 +208,17 @@ function logoffAndBackToLoginPage() {
die(); die();
} }
/**
* Returns if debug messages are to be logged.
*
* @return boolean debug enabled
*/
function isDebugLoggingEnabled() {
if (isset($_SESSION['cfgMain'])) $cfg = $_SESSION['cfgMain'];
else $cfg = new LAMCfgMain();
return $cfg->logLevel >= LOG_DEBUG;
}
/** /**
* Puts a new message in the log file. * Puts a new message in the log file.
* *