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 MartinMessage
How to build a whitelist from Windows Active Directory
2007-04-30 by Christopher A. Martin
Attachments
- No local attachments were found for this message.