Fix ldap login

forward port of #5425
verified that issue still exists in OC6 and that the fix works
This contribution is MIT licensed.
@blizzz