This needs checking against LDAP improvements PR.