mikie mike wrote:
1. Check LDAP database if there is such an user / alias in Exchange AD
If yes, mail should be transported to Exchange
2. Check if there is virtual user / alias in virtual table
If yes, mail goes to local maildir.
I don't know how to handle transports with LDAP. Is it possible to
transport user to Exchange if there is a record for her in LDAP?
Or should I do it other way?
You can use perl script. such as:
#!/usr/bin/perl
# ad2recipientmaps.pl
# (C) Eugene V. Boontseff
use Net::LDAP;
use Text::Iconv;
use MIME::Base64;
$server = "AD.domain.com"; #AD server
$port = "3268"; #AD ldap port
$basedn = "dc=domain,dc=com"; # base dn
$scope = "sub";
$binddn = "DOMAIN\\user"; # ms user
$passwd = "password"; # password
$filter = "(|(smtp=*)(SMTP=*))"; # filter
$ok = "OK";
$eol = "\n ";
$c = new Net::LDAP($server, port => $port) || die "Don't connect to
server $server: $...@\n";
$c->bind($binddn, password => $passwd) || die "Don't login: $...@\n";
$mesg = $c->search(base => $basedn, scope => $scope, filter => $filter)
or die "Don't search. code: #".$mesg->code();
my $max = $mesg->count;
for($i = 0 ; $i < $max ; $i++) {
my $entry = $mesg->entry($i);
foreach my $attr ($entry->attributes) {
$attrref=$entry->get_value($attr,asref => TRUE);
for ($j = 0 ; $j < scalar(@$attrref) ; $j++) {
if ($attr =~ /smtp/i) {
$print_attr = @$attrref[$j];
printf("%s\t%s%s",$print_attr,$ok,$eol);
}
}
}
}
$c->unbind();
exit 0;
./ad2recipientmaps.pl > relay_recipient_maps
postmap hash:relay_recipient_maps
cut on main.cf
...
transport_maps = hash:$config_directory/transport
relay_domains = domain.com
relay_recipient_maps = hash:$config_directory/relay_recipient_maps
...
cut off main.cf
cut on transport
...
domain.com smtp:exchange_server
...
cut on transport