[Mimedefang] Exchange2AccessPaged help?
Kees Theunissen
theuniss at rijnh.nl
Wed Aug 1 19:00:05 EDT 2007
On Wed, 1 Aug 2007, Kimmo Jaskari wrote:
>I had issues with getting the scripts at peregrinehw.com to work for me
>on Solaris, though; I did check the INSTALL bit and made sure I had the
>dependencies installed for Perl but the export script still choked,
>either complaining about the username/password combo or apparently
>running for a fast second but producing no output whatsoever. Again, the
>cut and paste school for Perl programming didn't cover that. ;)
I had about the same Perl skills when I started to use
MimeDefang a year ago.
I wrote a bash script script at that time to extract
valid email addresses from my Exchange 2003 server and create
sendmail maps (for the LDAP routing feature, with local tables
in my case). The script runs on a fedora linux system.
The relevant part of that script that queries the Exchange 2003
server for valid email addresses:
---------------------------------------
#! /bin/bash
if ! tempfile=$( mktemp -p . )
then
echo "Error creating temporary file" >&2
echo "Aborting" >&1
exit 1
fi
if ! ldapsearch -H ldap://exchangeserver:3268 \
-D valid_user at example.com \
-y password_file \
-b DC=example,DC=com \
-x -LLL \
'(&(!(cn=SystemMailbox{*}))
(!(showInAdvancedViewOnly=TRUE))
(!(msExchHideFromAddressLists=TRUE))
(mailnickname=*)
(|(&(objectCategory=person)
(objectClass=user)
(|(homeMDB=*)(msExchHomeServerName=*))
)
(objectCategory=group)
(objectCategory=msExchDynamicDistributionList)
(objectCategory=publicFolder)
)
)' proxyaddresses sAMAccountName >$tempfile
then
rm -f $tempfile
echo "Error extracting exchange addresses." >&2
echo "Aborting." >&2
exit 1
fi
# Unfold wrapped lines in the ldapsearch output
# and extract the email addresses.
tr '\n' '\t' < $tempfile \
| sed -e 's/\t //g' \
| tr '\t' '\n' \
| awk -F: 'BEGIN { IGNORECASE = 1 }; \
/^proxyAddresses: smtp:.*@example.com/ {print $3}'
rm -f $tempfile
---------------------------------------
I'm unfolding wrapped lines by replacing newlines with tabs,
deleting any combination of a tab immediately followed by a space,
and replacing the remaning tabs with newlines again.
This works fine on my domain with a few hundred of users, but for
large domains this might hit a maximum line length that 'sed'
can handle. I'm not sure about that.
Perl would do a better job here I think.
Regards,
Kees.
--
Kees Theunissen
F.O.M.-Institute for Plasma Physics Rijnhuizen, Nieuwegein, Netherlands
E-mail: theuniss at rijnh.nl, Tel: (+31|0)306096724, Fax: (+31|0)306031204
More information about the MIMEDefang
mailing list