Skip to content

Commit

Permalink
MDL-28402 LDAP configuration values being stored in lower case, causi…
Browse files Browse the repository at this point in the history
…ng misconfiguration

It looks like array_change_key_case() does not work recursively, so we
were not actually lowercasing the expiration attribute key. As the
configuration setting is always lowercase they didn't match.
  • Loading branch information
iarenaza authored and stronk7 committed Aug 28, 2011
1 parent a014e3b commit fa5f5c2
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions auth/ldap/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -579,16 +579,17 @@ function password_expire($username) {
$sr = ldap_read($ldapconnection, $user_dn, '(objectClass=*)', $search_attribs);
if ($sr) {
$info = ldap_get_entries_moodle($ldapconnection, $sr);
$info = array_change_key_case($info, CASE_LOWER);
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);
if (!empty ($info)) {
$info = array_change_key_case($info[0], CASE_LOWER);
if (!empty($info[$this->config->expireattr][0])) {
$expiretime = $this->ldap_expirationtime2unix($info[$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);
}
}
}
}
Expand Down

0 comments on commit fa5f5c2

Please sign in to comment.