1

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".

Sara Diaz
  • 73
  • 6

1 Answers1

0

try "memberOf" attribute with name of specific group.

You might want to look e.g. here, it is C# related, but I guess it will give you an impression of how user entries are constructed. You need objects of class "person" - objectCategory="person" - and containing attribute "memberOf" filled with name of group you're searching for. The whole list on result will contain all persons belonging. It should probably work with memberOf="test" as well, to include members of testA, and members of testB and members of testC, and more like for all group names matching.

Get List of Users From Active Directory In A Given AD Group

Community
  • 1
  • 1
Piotr Wadas
  • 1,838
  • 1
  • 10
  • 13