Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 1.6, 1.8, 1.9
-
Component/s: Authentication
-
Labels:None
-
Database:MySQL
-
Affected Branches:MOODLE_16_STABLE, MOODLE_18_STABLE, MOODLE_19_STABLE
-
Fixed Branches:MOODLE_18_STABLE, MOODLE_19_STABLE, MOODLE_20_STABLE
Description
auth_ldap_sync_users.php fails with "Cannot update non-existent user" when updating usernames containing capital letters.
In auth/ldap/auth.php, in function update_user_record(), the following line is converting the username to lowercase, causing the get_record() lookup to fail with no match on the username:
$username = trim(moodle_strtolower($username));
Here is an example of the output from auth_ldap_sync_users.php:
Got 1151 records from LDAP
User entries to update: 1332
Updating user ldap.test id 792
Updating user ann.bolton id 488
Updating user olivian.roddenby id 1538
Updating user SBCS - ASP id 590Cannot update non-existent user: sbcs - asp
Commenting out the strtolower line fixes this.
Also as a subsequent bug, the update_user_record function in auth/ldap/auth.php calls print_error which prints out a HTML error page, however auth_ldap_sync_users.php is not intended to be called from a web server so should have plain text output suitable for cron emails.
As far as I remember, usernames in Moodle were all stored in lower case all the time, but things have changed there a lot more recently.
Yu, can you check what the current rule is?
ie
1) usernames should always be lowercased in the database or
2) usernames are case-sensitive