Getting Email Ids for multiple users - from AD server.Hi,
I have added ADSI as linked server and running below query to get EmailIds for the respective sAMAccountName as mentoned below.
SELECT * FROM OPENQUERY
(ADSI,'SELECT name,mail, sAMAccountName, distinguishedName
WHERE objectCategory = ''Person'' AND objectClass = ''user'' AND sAMAccountName=''b10fn''' )
This is working but I have multiple user so I have to get Email-ids for all the users (similar to user = b10fn)
Please suggest me how can I take it as parameter so that I can pass various user IDs(sAMAccountName) and get Email-Ids.