From: joe [mailto:email@example.com]
Subject: RE: ADFIND – Group + Members Query
You can’t do this in one query, it will take at least two.
First query would be to find the group and dump its memberof values.
adfind -default –f "&(objectcategory=group)(name=groupname)" memberof
The second query (or set of queries) would be to dump the SMTP addresses of the members.
If you know that the members are all in the same domain as the group you can use this shortcut
adfind -this "group DN" -asq member mail
If the members could be in different domains, this can be done with a single command line but will be multiple queries. Specifically a query for every single member + 1
adfind -this "group DN" member -qlist | adfind mail
If you don’t need memberof this could be done in one command line
adfind -default -f "&(objectcategory=group)(name=groupname)" member -qlist | adfind mail
Oh that also assumes that mail will be the only SMTP address you need, if you need the primary and secondaries then this gets more complicated and would look like
adfind -default -f "&(objectcategory=group)(name=groupname)" member -qlist | adfind proxyaddresses -mvfilter proxyaddresses=smtp
And if you want that in CSV format, you simply add –CSV to the end
adfind -default -f "&(objectcategory=group)(name=groupname)" member -qlist | adfind proxyaddresses -mvfilter proxyaddresses=smtp -csv
Note that you may not be able to cut and paste the commands, sometimes outlook puts characters in that the CMD Prompt doesn’t like.
O’Reilly Active Directory Fourth Edition – http://www.joeware.net/win/ad4e.htm
Subject: ADFIND – Group + Members Query
I hope you are doing fine.
I need a query to 1. find a specific group, 2. dump it’s members, 3. the groups this group is member of and also 4. dump the smtp address of the group’s members.
I managed to build the following query:
adfind -gcb -f "&(objectClass=group)(name=_test1)" member memberof
I was able to achieve the items 1, 2 and 3, but the 4th one is a bit difficult. Is it possible to be done?