Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Map Perdition IMAP proxy to mailboxes on multiple Exchange servers

by BravoTwoZero (Scribe)
on Aug 30, 2004 at 16:22 UTC ( #386951=sourcecode: print w/replies, xml ) Need Help??
Category: E-mail Programs
Author/Contact Info BravoTwoZero
Description:

We replaced Outlook Web Access with Squirrelmail/Perdition running on Debian Linux. The problem is that, with 1,000 users who are unknowing of which mail server holds their mailbox, we decided on an IMAP proxy to Exchange (Perdition).

This script generates Perdition's popmap config file from a dump of the Exchange directory and restarts Perdition. Details on generating the directory dump are here: http://www.unixwiz.net/techtips/postfix-exchange-users.html. I'd love to hear of someone found the HOME_SERVER variable via LDAP lookups to Exchange. It might be right in front of me, but I don't see it. I don't cover the Squirrelmail or Perdition configs, either. Here's my version of the two config files and one batch file mentioned at the above link for this script:

userexport.ini
Important note: use the netbios name of the Exchange server. It always fails for me if I use a FQDN.

[Export] DirectoryService=EXCHANGESERVER Basepoint= Container=Recipients ExportObject=All InformationLevel=Minimal BasepointOnly=No RawMode=No HiddenObjects=Yes Subcontainers=No CodePage=0 ; 09 = TAB ColumnSeparator=09 ; 37 = % MVSeparator=37 ; 34 = " QuoteCharacter=34

and

exportfields.txt

Obj-Class Alias Name Home-Server

and

runexport.bat

c: cd \bin\exexport copy exportfields.txt exchusers.txt \exchsrvr\bin\admin /e exchusers.txt /n /o userexport.ini

#!/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);
  • Comment on Map Perdition IMAP proxy to mailboxes on multiple Exchange servers
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://386951]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (10)
As of 2021-01-28 14:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?