Skip to content
Browse files

auth/ldap: MDL-9405 sync_users() can create duplicated users

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...
1 parent 2c0c202 commit bb53eb49a8dd3170f3d560057647e033efe30ff3 iarenaza committed Dec 26, 2008
Showing with 3 additions and 0 deletions.
  1. +3 −0 auth/ldap/auth.php
View
3 auth/ldap/auth.php
@@ -671,6 +671,9 @@ function sync_users ($bulk_insert_records = 1000, $do_updates = true) {
$user->confirmed = 1;
$user->auth = 'ldap';
$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)) {
$user->lang = $CFG->lang;
}

0 comments on commit bb53eb4

Please sign in to comment.
Something went wrong with that request. Please try again.