#!/usr/bin/perl
#
# perditionusers.pl
#
# We use this to run an ldap query to an Exchange 5.5 server
# so we can generate a Perdition proxy list for internal Exchange
# servers.
#
# You'll have to dump the Exchange directory using instructions
# here: http://www.unixwiz.net/techtips/postfix-exchange-users.html
# before running the script. And, you'll have to get that dump
# to the Perdition server, too.
#
# Don't forget my versions of the above configs and batch files
# in the description at:
# http://www.perlmonks.org/index.pl?node_id=386951
#
use File::Copy;
# for what domain will we search in the mail addresses?
$domain = "yourdomain.com";
# path to relay_recipients file/db: current, new and backups
$perdition_dir = "/etc/perdition";
$exchusers = "$perdition_dir/exchusers.txt";
$imapusers = "$perdition_dir/imapusers.txt";
$popmap = "$perdition_dir/popmap";
# postfix db rebuild and reload command
$perdition_stop = "/etc/init.d/perdition stop";
$perdition_start = "/etc/init.d/perdition start";
# localize the results array variable
my @results;
open (EXCH, "< $exchusers");
# while the filehandle has data...
while (<EXCH>) {
# remove the trailing newline
chomp;
if (/^Mailbox/) {
$_ = lc $_;
($mb,$alias,$homesrv) = split /\t/;
push @results, "$alias:$alias\@$homesrv.$domain";
}
}
# close the filehandle
close EXCH;
open (IMAP, "> $imapusers") or die "Can't open $imapusers $!\n";
foreach $line (@results) {
print IMAP "$line\n"
# print "$line\n"
}
close IMAP;
copy($popmap,"$popmap.bak");
copy($imapusers,$popmap);
chdir($perdition_dir);
system("make");
system($perdition_stop);
system($perdition_start);
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.