From 997bcd9e26b175e70e2afa4cbaf09a5d2e7bbec8 Mon Sep 17 00:00:00 2001 From: iarenaza Date: Fri, 26 Dec 2008 16:01:30 +0000 Subject: [PATCH] auth/ldap: MDL-9405 sync_users() can create duplicated users Merged from MOODLE_18_STABLE 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. --- auth/ldap/auth.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/auth/ldap/auth.php b/auth/ldap/auth.php index c2f674c64d..35cda41623 100644 --- a/auth/ldap/auth.php +++ b/auth/ldap/auth.php @@ -795,6 +795,9 @@ class auth_plugin_ldap extends auth_plugin_base { $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; } -- 2.39.5