How to use dsquery to find a u AD user who manages an group

I have a user who I need to determine which groups he is the owner of and export those reults to a text file. The trick here is we utilize TWO domains and so I would need to be able to find which groups he manages in both domains.

I have tried:

dsquery * domainroot -filter "(&(objectCategory=Group)(managedby=""LastName\, FirstName""))" -attr name > C:\Temp\managedby.txt

I get results from this, but his name does not appear in those results, even though I know specific groups he indeed is the owner of.

The domains are designed as: dom1.va.gov and dom2.sub1.va.gov (these are examples, not the actual domains)

Suggestions?

February 19th, 2013 2:58pm

You need to specific the users DN in the query for the managedBy attribute like:
"(&(objectCategory=Group)(managedby="CN=Administrator,CN=Users,DC=domain,DC=com"))"

Free Windows Admin Tool Kit Click here and download it now
February 19th, 2013 3:08pm

OK, so I tried that suggestion but the text file is still empty of any results...

Thied this:

dsquery * domainroot -filter "(&(objectCategory=Group)(managedby=""CN=User\, Joe,CN=Dept,CN=Users,DC=dom1,DC=va,DC=gov""))" -attr name > managedby.txt

this:

dsquery * domainroot -filter "(&(objectCategory=Group)(managedby="CN=User\, Joe,CN=Dept,CN=Users,DC=dom1,DC=va,DC=gov"))" -attr name > managedby.txt

And this:

dsquery * domainroot -filter "(&(objectCategory=Group)(managedby=""CN=User\, Joe,OU=Dept,OU=Users,DC=dom1,DC=va,DC=gov""))" -attr name > managedby.txt

No luck...

February 19th, 2013 3:47pm

I think you have too many quotes. The DN does not need to be quoted in the command. Try:

dsquery * domainroot -filter "(&(objectCategory=Group)(managedby=CN=User\, Joe,CN=Dept,CN=Users,DC=dom1,DC=va,DC=gov))" -attr name > managedby.txt

Free Windows Admin Tool Kit Click here and download it now
February 19th, 2013 7:38pm

Use a batch file if you are not already. Type in what the group name would start with after the "-name" parameter. 

dsquery group -name staff > e:\groups_list.txt

for /F "tokens=*" %%i in (e:\groups_list.txt) do (

dsquery group %%i -o rdn >> e:\group_answer.txt

dsquery * %%i -attr managedBy >> e:\group_answer.txt

)

May 21st, 2015 9:10pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics