[Mimedefang] Validating Exchange addresses

John Rowan Littell littejo at earlham.edu
Tue Oct 7 08:42:00 EDT 2003


-----BEGIN PGP SIGNED MESSAGE-----

Lo, Kenneth Porter and the coffee pot sang in unison:

> Inspired by some samples, I've come up with the following one liner that seems
> to get all addresses from an Exchange server:
>
> ldapsearch -h "$server" -x -P2 -s sub "objectclass=*" | awk '/^mail:/{print
> $2;}'
>
[snip]
>
> Is this going to miss anything? Is there a more efficient way to make the
> query? (I'm an LDAP newb with only the glossiest idea of its query system.)

Be nice to your LDAP server and only request the mail attribute.  Your
ldapsearch command would then look like:

ldapsearch -h $server -x -P2 -s sub "objectclass=*" mail

If you stick a '-LLL' in the ldapsearch command line, then you'll have
even less work for awk to do, as the output will look something like
this:

dn: blahblahblah
mail: foo at example.org

dn: blublublub
mail: bar at example.org

...

A quick browse through the man page doesn't show me a way of removing
the DN lines from the output, though, so I think you'll still neet
that awk statement.

  --rowan

- -- 
John "Rowan" Littell
Systems Administrator
Earlham College Computing Services
http://www.earlham.edu/~littejo/
2003-10-07 07:32
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (Darwin)
Comment: Made with pgp4pine 1.76

iQCVAwUBP4K0Z5dUNSJ2nf/5AQHkNgP/dRcP+jds3h+fypUOa/DqSLRtLp5UIvPd
7Dvk6Wco1dm+Xlmd+YqNKjpEuXWsQqHOxSd+4pBta2ga3hMujL3c1FfPfvqsWVNu
HM1ez93t0sp7m4R3a0M9TPKQYYClz55N8RjG4fp5LhLkixgNjvZy78KkLkS9OKVL
4YXRLPH8CVc=
=4WLE
-----END PGP SIGNATURE-----




More information about the MIMEDefang mailing list