Find User DN
Many command takes full user DN as option. Below command find user DN those names start with “Smith”. ‘*’ is the wildcard character and can be used anywhere in the string.
dsquery user -name "Smith*"
Find Group DN
Similar to user DN:
dsquery group -name "MyGroup*"
List Users In Group
Use command below to find all users in a given AD security group. Replace <groupDN> with actual group DN.
dsget group <groupDN> -members | find /i "cn=users"
List All Groups Who Is a Member Of
Use command below to find all the group a given AD name belongs to. Replace <DN> with actual user DN or group DN.
dsget user <DN> -memberof