Skip to content

Commit

Permalink
MDL-24666 sync_users.php can throw db exception on sites upgraded fro…
Browse files Browse the repository at this point in the history
…m 1.x

From 2.0 on we lowercase all the settings related to LDAP attributes
to cope with differences in LDAP servers when returning attribute
names as array indices (some lowercase them, some leave them as
specified in the query, some normalize them, etc.).

But we only lowercase them when saving the settings page. So on sites
that have been migrated from 1.x, it may happen that we still have
mixed-case attribute names. And this is fatal for the user_attribute
setting, as we might not detect it in the returned array from LDAP and
it will be empty (and the db layer throws and exception).

So we just make sure the attribute name is lowercased (and trimmed,
in case it's got some white space around it).

Signed-off-by: Iñaki Arenaza <iarenaza@mondragon.edu>
  • Loading branch information
iarenaza committed Jul 4, 2011
1 parent 81f8e0f commit 971db6a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion auth/ldap/auth.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1385,7 +1385,7 @@ function ldap_attributes () {
} }
} }
} }
$moodleattributes['username'] = $this->config->user_attribute; $moodleattributes['username'] = moodle_strtolower(trim($this->config->user_attribute));
return $moodleattributes; return $moodleattributes;
} }


Expand Down

0 comments on commit 971db6a

Please sign in to comment.