Get LDAP Auth running

The LDAP authentication does not work because of
multiple problems in 2.5

We fixed them so that now it is possible to authenticate users
agains LDAP.

Most things look like something was changed but not tested with LDAP.
We hope our fixes make sense, at least it the work in our case and
so people that want to use LDAP can at least start on this version.