Navigation Menu

Skip to content

Commit

Permalink
auth/ldap: MDL-9405 sync_users() can create duplicated users
Browse files Browse the repository at this point in the history
If we are using auth_ldap_sync_users.php to synchronize our users, and we
have a database which is case-sensitive when doing comparisons (Postgres and
Oracle at least), and any of our users has the vale of the username attribute
in mixed-case (like 'John Smith'), we get duplicated users.

This is because we don't make sure the username attribute value is 'lowercased'
after we retrive it from the LDAP server and before we insert it into the
database.
  • Loading branch information
iarenaza committed Dec 26, 2008
1 parent 2c0c202 commit bb53eb4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions auth/ldap/auth.php
Expand Up @@ -671,6 +671,9 @@ function sync_users ($bulk_insert_records = 1000, $do_updates = true) {
$user->confirmed = 1; $user->confirmed = 1;
$user->auth = 'ldap'; $user->auth = 'ldap';
$user->mnethostid = $CFG->mnet_localhost_id; $user->mnethostid = $CFG->mnet_localhost_id;
// get_userinfo_asobj() might have replaced $user->username with the value
// from the LDAP server (which can be mixed-case). Make sure it's lowercase
$user->username = trim(moodle_strtolower($user->username));
if (empty($user->lang)) { if (empty($user->lang)) {
$user->lang = $CFG->lang; $user->lang = $CFG->lang;
} }
Expand Down

0 comments on commit bb53eb4

Please sign in to comment.