Yahoo Groups archive

Milter-greylist

Index last updated: 2026-04-28 23:32 UTC

Message

How to build a whitelist from Windows Active Directory

2007-04-30 by Christopher A. Martin

Hello the list!

For anyone who's interested in generating a whitelist or greylist from
Active Directory using OpenLDAP (the example below is for a whitelist),
here's a script that should work (please excuse any mangled line
feeds!). The part 1 and 2 files were derived from greylist.conf.sample.
The script doesn't actually instate the conf file and restart the
greylist milter as this is done in the cron script that calls this
script.


# /usr/local/bin/get_ad_emails
#!/bin/sh

rm /tmp/ldapdump.txt
rm /tmp/alluseremails.txt

ldapsearch -Hldap://dc.domain.tld -x -D "user@..." -b
"ou=Staff,dc=domain,dc=tld" -u password -s sub "(objectclass=person)"
proxy Addresses > /tmp/ldapdump.txt

cat /tmp/ldapdump.txt | grep @emaildomain | sed 's/proxyAddresses:
SMTP:/ /' | sed 's/proxyAddresses: smtp:/ /' > /tmp/alluseremails.txt

rm /usr/local/etc/mail/greylist.conf.new
cat /usr/local/etc/mail/greylist.conf.part1 >>
/usr/local/etc/mail/greylist.conf.new
printf "\n"  >> /usr/local/etc/mail/greylist.conf.new
printf "# Whitelist\n" >> /usr/local/etc/mail/greylist.conf.new
printf "list \0042local users\0042 rcpt {  \\" >>
/usr/local/etc/mail/greylist.conf.new
printf "\n" >> /usr/local/etc/mail/greylist.conf.new
cat /tmp/alluseremails.txt | sed 's/$/ \\/g' >>
/usr/local/etc/mail/greylist.conf.new
printf "}\n" >> /usr/local/etc/mail/greylist.conf.new
printf "\n" >> /usr/local/etc/mail/greylist.conf.new
cat /usr/local/etc/mail/greylist.conf.part2 >>
/usr/local/etc/mail/greylist.conf.new


Hope this saves someone else some pain!

Chris Martin

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.