From: skodak Date: Mon, 21 May 2007 20:08:45 +0000 (+0000) Subject: MDL-9861 Password expiration value is calculated wrong when ldap_expirationtime2unix... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=2cef74f91f58a3c8bcf79ec81af3f9068509f78d;p=moodle.git MDL-9861 Password expiration value is calculated wrong when ldap_expirationtime2unix() returns 0 - patch by IƱaki Arenaza; merged from MOODLE_18_STABLE --- diff --git a/auth/ldap/auth.php b/auth/ldap/auth.php index 67a62b44b6..2b6d8aa704 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 {