Move internal authentication code to new function.

This is in preparation of adding LDAP based authentication.
Add function to check if user is an LDAP user.
Implement LDAPAuthenticate function.
Display use_ldap flag in user management.

Code for actually editing this boolean still needs writing.