Some fixes on LDAP authentication process

This does not fix entirely the current issues related to the LDAP
authentication mechanisms, but should fix cas + LDAP setups.