diff --git a/auth/cas/auth.php b/auth/cas/auth.php index 8e137eb1a4b..fb42870df0b 100644 --- a/auth/cas/auth.php +++ b/auth/cas/auth.php @@ -500,6 +500,7 @@ if ( !is_object($PHPCAS_CLIENT) ) { } } } + $moodleattributes['username'] = $this->config->user_attribute; return $moodleattributes; } /** diff --git a/auth/db/auth.php b/auth/db/auth.php index ba3cf7529f7..c0f57aff6fa 100644 --- a/auth/db/auth.php +++ b/auth/db/auth.php @@ -137,6 +137,7 @@ class auth_plugin_db extends auth_plugin_base { $moodleattributes[$field] = $this->config->{"field_map_$field"}; } } + $moodleattributes['username'] = $this->config->fielduser; return $moodleattributes; } diff --git a/auth/ldap/auth.php b/auth/ldap/auth.php index e3902a72d5c..d7eeea7e49a 100644 --- a/auth/ldap/auth.php +++ b/auth/ldap/auth.php @@ -1637,6 +1637,7 @@ class auth_plugin_ldap extends auth_plugin_base { } } } + $moodleattributes['username'] = $this->config->user_attribute; return $moodleattributes; } diff --git a/auth/shibboleth/auth.php b/auth/shibboleth/auth.php index 84309c28a9c..8ed938150fe 100644 --- a/auth/shibboleth/auth.php +++ b/auth/shibboleth/auth.php @@ -128,6 +128,7 @@ class auth_plugin_shibboleth extends auth_plugin_base { $moodleattributes[$field] = $configarray["field_map_$field"]; } } + $moodleattributes['username'] = $configarray["user_attribute"]; return $moodleattributes; } diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 14ba40c7736..b8ac39df34a 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -2831,6 +2831,10 @@ function update_user_record($username, $authplugin) { if ($newinfo = $userauth->get_userinfo($username)) { $newinfo = truncate_userinfo($newinfo); foreach ($newinfo as $key => $value){ + if ($key === 'username') { + // 'username' is not a mapped updateable/lockable field, so skip it. + continue; + } $confval = $userauth->config->{'field_updatelocal_' . $key}; $lockval = $userauth->config->{'field_lock_' . $key}; if (empty($confval) || empty($lockval)) {