From 2cef74f91f58a3c8bcf79ec81af3f9068509f78d Mon Sep 17 00:00:00 2001 From: skodak Date: Mon, 21 May 2007 20:08:45 +0000 Subject: [PATCH] =?UTF-8?q?MDL-9861=20Password=20expiration=20value=20is?= =?UTF-8?q?=20calculated=20wrong=20when=20ldap=5Fexpirationtime2unix()=20r?= =?UTF-8?q?eturns=200=20-=20patch=20by=20I=C3=B1aki=20Arenaza;=20merged=20?= =?UTF-8?q?from=20MOODLE=5F18=5FSTABLE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- auth/ldap/auth.php | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/auth/ldap/auth.php b/auth/ldap/auth.php index 67a62b44b67..2b6d8aa7042 100644 --- a/auth/ldap/auth.php +++ b/auth/ldap/auth.php @@ -291,7 +291,7 @@ class auth_plugin_ldap extends auth_plugin_base { * @return integer */ function password_expire($username) { - $result = false; + $result = 0; $textlib = textlib_get_instance(); $extusername = $textlib->convert(stripslashes($username), 'utf-8', $this->config->ldapencoding); @@ -302,19 +302,16 @@ class auth_plugin_ldap extends auth_plugin_base { $sr = ldap_read($ldapconnection, $user_dn, 'objectclass=*', $search_attribs); if ($sr) { $info = $this->ldap_get_entries($ldapconnection, $sr); - if (empty ($info) or empty($info[0][$this->config->expireattr][0])) { - //error_log("ldap: no expiration value".$info[0][$this->config->expireattr]); - // no expiration attribute, password does not expire - $result = 0; - } - else { - $now = time(); - $expiretime = $this->ldap_expirationtime2unix($info[0][$this->config->expireattr][0]); - if ($expiretime > $now) { - $result = ceil(($expiretime - $now) / DAYSECS); - } - else { - $result = floor(($expiretime - $now) / DAYSECS); + if (!empty ($info) and !empty($info[0][$this->config->expireattr][0])) { + $expiretime = $this->ldap_expirationtime2unix($info[0][$this->config->expireattr][0], $ldapconnection, $user_dn); + if ($expiretime != 0) { + $now = time(); + if ($expiretime > $now) { + $result = ceil(($expiretime - $now) / DAYSECS); + } + else { + $result = floor(($expiretime - $now) / DAYSECS); + } } } } else {