joeware - never stop exploring... :)

Information about joeware mixed with wild and crazy opinions...

From the mailbag… How to dump SMTP addresses for users in a group

by @ 9:09 pm on 2/19/2010. Filed under tech

From: joe [mailto:joe@joeware.net]
Sent: xxx
To: xxx
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.

   joe

O’Reilly Active Directory Fourth Edition – http://www.joeware.net/win/ad4e.htm

 

From: xxx
Sent: xxx
To: joe@joeware.net
Subject: ADFIND – Group + Members Query

Hi Joe,
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?
Cheers,

xxx

Rating 3.00 out of 5

3 Responses to “From the mailbag… How to dump SMTP addresses for users in a group”

  1. Hunter says:

    I hope this is the kind of stuff that will end up in the new book project…I’m always learning new stuff from your examples, despite how many times I’ve run adfind.exe -??

  2. joe says:

    Yep that is what I was thinking. 🙂

    My issue now as I am working on the outline is figuring out how big the book should be.

  3. Hunter says:

    Make it a coffee-table book, with lots of pretty pictures.

[joeware – never stop exploring… :) is proudly powered by WordPress.]