Refactor LDAP backend using context manager for connection

I added context manager support for getting connection in LDAP backend
to replace a large amount try-finally blocks to a simple "with"
statement. So both statements are supported now.

Change-Id: I3e3e29a97e6212177cf755719f404cc24204ea54