Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit bb53eb49a8dd3170f3d560057647e033efe30ff3 1 parent 2c0c202
iarenaza authored

Showing 1 changed file with 3 additions and 0 deletions. Show diff stats Hide diff stats

  1. +3 0  auth/ldap/auth.php
3  auth/ldap/auth.php
@@ -671,6 +671,9 @@ function sync_users ($bulk_insert_records = 1000, $do_updates = true) {
671 671 $user->confirmed = 1;
672 672 $user->auth = 'ldap';
673 673 $user->mnethostid = $CFG->mnet_localhost_id;
  674 + // get_userinfo_asobj() might have replaced $user->username with the value
  675 + // from the LDAP server (which can be mixed-case). Make sure it's lowercase
  676 + $user->username = trim(moodle_strtolower($user->username));
674 677 if (empty($user->lang)) {
675 678 $user->lang = $CFG->lang;
676 679 }

0 comments on commit bb53eb4

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