« 2 different methods of MS Terminal Service Remote Admin | Dangerous food, part 1 - Glutinous rice cakes (mochi) »

Custom ADUC query - Find a specific SMTP address in AD

Using a custom saved query in AD to find a specific SMTP address. This is helpful if you're having trouble finding the source of a conflicting SMTP address.

Limit search to users / contacts:
(&(objectCategory=user)(mail=address@mydomain.tld))

Wider search by SMTP address:
(&(proxyAddresses=smtp:address@mydomain.tld))


You can go further and query all users in a certain domain that aren't disabled.

(&(objectCategory=user)(mail=*@mydomain.tld)(!userAccountControl:1.2.840.113556.1.4.803:=2))

To do this from the command line, use CSVDE

csvde -f outputFile.csv -d "dc=mydomain,dc=tld" -r "(&(mail=*@mydomain.tld))" -l name -v -s addcname

using the following common switches:

-f is the output CSV file

-d is the base DN

-r is the LDAP formatted query

-l name will return just the name of the object. Drop this switch to return all attributes of the object.

-s is the DC name. You might need this in a larger environment with multiple domains.

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)