Move ldap code to lib