I am attempting to query my LDAP structure using the following SQL LDAP query and I am able to pull most all the users by samaccountname but I have a few users that the query is not finding. I have verified using a LDAP Browser to verify that the users do exist and the samaccountname is consist with all the other accounts. Any ideas why this might be happening?
, ISNULL(mail,'') as mail
FROM OPENQUERY(ADSI, 'SELECT sAMAccountName, mail, employeeId FROM ''LDAP://OURSERVER/CN=Users,DC=ONE,DC=TWO,DC=THREE,DC=com''')
order by sAMAccountName