Skip to content

Commit

Permalink
Update checkexpiration.php
Browse files Browse the repository at this point in the history
Ignore user with a pwdChangedTime if  policy have a pwdMaxAge  == 0
  • Loading branch information
konvergence authored Dec 11, 2017
1 parent 8b9f2dd commit dcd23a7
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions pages/checkexpiration.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,18 @@
}


$expireDateTime = clone $changeDateTime; $expireDateTime->modify('+'. $pwdMaxAge . ' seconde');
$warningDateTime = clone $changeDateTime; $warningDateTime->modify('+'. $pwdMaxAge . ' seconde'); $warningDateTime->modify('-'. $pwdExpireWarning . ' seconde');


error_log( "checkexpiration - user $login - policy MaxAge=$pwdMaxAge,ExpireWarning=$pwdExpireWarning - Current:" . $nowDateTime->format("Y-m-d H:i:s") . ", Changed:" . $changeDateTime->format("Y-m-d H:i:s") . ", Warning:" . $warningDateTime->format("Y-m-d H:i:s") .", Expired:" . $expireDateTime->format("Y-m-d H:i:s") );
$expireDateTime = clone $changeDateTime; $expireDateTime->modify('+'. $pwdMaxAge . ' seconde');
$warningDateTime = clone $changeDateTime; $warningDateTime->modify('+'. $pwdMaxAge . ' seconde'); $warningDateTime->modify('-'. $pwdExpireWarning . ' seconde');

# ignore $changeDateTime if $pwdMaxAge == 0
if ( $pwdMaxAge == 0) {
error_log( "checkexpiration - user $login - policy MaxAge=$pwdMaxAge - Ignore expiration");
}else{
error_log( "checkexpiration - user $login - policy MaxAge=$pwdMaxAge,ExpireWarning=$pwdExpireWarning - Current:" . $nowDateTime->format("Y-m-d H:i:s") . ", Changed:" . $changeDateTime->format("Y-m-d H:i:s") . ", Warning:" . $warningDateTime->format("Y-m-d H:i:s") .", Expired:" . $expireDateTime->format("Y-m-d H:i:s") );
}

#if password is in expire periode, send notify it the 1st day of warning, and the last day
if( $nowDateTime >= $warningDateTime && $nowDateTime < $expireDateTime) {
if( $pwdMaxAge > 0 && $nowDateTime >= $warningDateTime && $nowDateTime < $expireDateTime) {

$expireInUnits = $nowDateTime->diff($expireDateTime)->days;

Expand All @@ -210,7 +214,7 @@
}
}else{
# if password is expired, the notify the 1st day of expiration
if ( $nowDateTime >= $expireDateTime) {
if ( $pwdMaxAge >0 && $nowDateTime >= $expireDateTime) {

$expireInUnits = $expireDateTime->diff($nowDateTime)->days;

Expand Down

0 comments on commit dcd23a7

Please sign in to comment.