The How-To Geek Forums Have Migrated to Discourse

How-To Geek Forums / Windows 7

(Solved) - AD Query

(3 posts)
  • Started 4 years ago by alexak
  • Latest reply from Drizzle
  • Topic Viewed 276 times

Posts: 23

Hi guys,

i need to query the AD to find the group membership for number of users, could you please suggest which command i need to use

now i am using dsquery to get it, but the below command which i am using is needed to edit every time with appropriate group id, where as i need to get all the groups of a given user with single command -- is it possible?

dsquery group -name "group name" | dsget group -members

thank you

Posted 4 years ago
Posts: 23


i got the solution

first we need to get the DN of the user with following command

DSQUERY.exe * -limit 0 -filter "(&(objectCategory=Person)(objectClass=User)(!userAccountControl:1.2.840.113556.1.4.803:=2))" >"User-DN.txt"

then use the DN to get the group membership
dsget user <UserDN> -memberof

thank you,

Posted 4 years ago
Posts: 2045

H alexak

Pleased you worked out the info..well done.
Thanks for posting result here for anyone else searching .
Good luck

Posted 4 years ago

Topic Closed

This topic has been closed to new replies.