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.
Taking into account FXP's feedback
Merge pull request #448 from pmauduit/issue-440

Some fixes on LDAP authentication process