Taken from http://www-personal.umich.edu/~malth/gaptuning/postfix/ however note that the "your_recipients" file in the postfix main.cf, the "plusone_recipients" in the cron job, and the "example_recipients" in the Perl file should probably all be the same. -- wl 200808
This method consists of a simple perl script which uses Net::LDAP to retrieve Active Directory users' "proxyAddresses" which are both primary and secondary SMTP addresses (as opposed to using "mail" which would only retrieve a user's primary SMTP address). Nothing needs to be run on the Active Directory domain controllers; this script requires only TCP port 389 access to your Active Directory domain controllers
The resulting output is in the format: "firstname.lastname@example.org OK" which then must be postmap(ped).
Add the following to your Postfix 2.0+ main.cf to use the relay_recipient_maps feature of Postfix, which will now reject unknown users:
relay_recipient_maps = hash:/etc/postfix/your_recipients
Note: the Exchange domains in question MUST be entered in relay_domains, and NOT in mydestination.
Also note if you would like to prevent Postfix from rejecting with "User unknown in relay recipient table" and would rather Postfix say "User unknown" set show_user_unknown_table_name = no in main.cf.
I have the script cronned every hour with the following cron job:
#!/bin/sh cd /etc/postfix ; ./getadsmtp.pl && postmap plusone_recipients
Conceivably this script can be easily modified to support other LDAP servers by changing the M$-specific "proxyAddresses" search base and output modification.