From 66a1b435659bb9795d1b1802f0776460dc6ca8af Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sun, 15 Oct 2017 10:22:19 +0200 Subject: [PATCH] expiration status --- lam/lib/modules/shadowAccount.inc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lam/lib/modules/shadowAccount.inc b/lam/lib/modules/shadowAccount.inc index 4e539546..49107aaf 100644 --- a/lam/lib/modules/shadowAccount.inc +++ b/lam/lib/modules/shadowAccount.inc @@ -771,6 +771,22 @@ class shadowAccount extends baseModule implements passwordService { ); } + /** + * Returns if the given account is expired. + * + * @param array $attrs LDAP attributes + * @return bool expired + */ + public static function isAccountExpired($attrs) { + $attrs = array_change_key_case($attrs, CASE_LOWER); + if (empty($attrs['shadowexpire'][0])) { + return false; + } + $time = new DateTime('@' . $attrs['shadowexpire'][0] * 24 * 3600, new DateTimeZone('UTC')); + $now = new DateTime(null, getTimeZone()); + return ($time > $now); + } + } if (interface_exists('\LAM\JOB\Job', false)) {