We have a Moodle system which is connected to a LDAP server for authentication. Moodle accounts are created on the fly as soon as a user logs in for the first time.
If $CFG->authloginviaemail is enabled, logging into Moodle with my email address as username works fine.
Unfortunately, the login fails for first-time logins - I assume this is because Moodle does not know my mailaddress yet and can only match my username to the uid attribute in LDAP.
This "bootstrap problem" is problematic when we tell our students that they don't have to remember their LDAP uid and can login with their mailaddress.
I think this has to be solved, for example by extending the LDAP plugin with a mechanism which looks for the mailaddress in LDAP at login time and gets the user's uid to proceed the normal authentication process.