changed function to use ldap