Resolution: Cannot Reproduce
Affects Version/s: 1.8.4, 1.9.16
Fix Version/s: None
In the creation of the temporary table in auth/ldap/auth.php's sync_users() function, there are two issues:
1) the width of the username column is set to 64, whereas mdl_user.username is 100 characters.
C.f. auth/ldap/auth.php version 1.47, lines 538, 543, 549, 555
2) there is no reference to the mnethostid in the temporary table.
This second issue becomes a significant problem when sync_users() performs the User Additions section. Because mdl_user.username is only indexed in mdl_user_mneuse_uix, the select is EXTREMELY slow and resource intensive. MySQL would lock up for several minutes on our site. I added a nonunique index to mdl_user.username to avoid the issue. Alternately, the local mnethostid could be utilized in the temptable and SQL.
C.f. auth/ldap/auth.php version 1.47, line 789.