From 971db6a11057c18227c50c5e7044ebcfd3473ce5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?I=C3=B1aki=20Arenaza?= Date: Mon, 4 Jul 2011 21:38:53 +0200 Subject: [PATCH 1/1] MDL-24666 sync_users.php can throw db exception on sites upgraded from 1.x MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- auth/ldap/auth.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auth/ldap/auth.php b/auth/ldap/auth.php index 1fd39092ba4..447b6a69d7f 100644 --- a/auth/ldap/auth.php +++ b/auth/ldap/auth.php @@ -1385,7 +1385,7 @@ class auth_plugin_ldap extends auth_plugin_base { } } } - $moodleattributes['username'] = $this->config->user_attribute; + $moodleattributes['username'] = moodle_strtolower(trim($this->config->user_attribute)); return $moodleattributes; } -- 2.43.0