How to control connection to LDAP