Refactored ldap and authentication a bit, added stub for testing.