AD bugfix and addtional option

A small patch to fix a bug in the AD LDAP code that prevents normal logins from succeeding.
Additionally a switch that will prevent non-LDAP logins (useful when only authorised domain users should be allowed access to the site).