Bugfix LDAP module

We are using the LDAP module for Gallery3 (version 3.0.6). Activating it caused a lot of pain, as I found some serious bugs. Here are some bug fixes which should make the LDAP plugin work in most cases. There's still an issue with additional groups, I will open an issue on Github for it.