I need to find all users in specific groups in Active Directory. I am able to query AD for the specific groups that i want to get users from but I am unable to query that specific group for users.
The following works:
SELECT *
FROM OPENQUERY
(ADSI
, 'SELECT cn, displayName, userPrincipalName
FROM ''LDAP://MY.CONNECTION.IS.HERE''
WHERE objectCategory=''group''
AND CN=''*TEST*''
ORDER BY CN')
The above query returns all AD groups that are like "test". But How do i go about getting a list of users from an ad GROUP? I specifically want to list the users in all groups that are like "test".