Kind of; mine may not suit you though; I have Exchange Servers on the back end; So I have one script that pulls from Active Directory and builds a sendmail compatible alias file that I push out to my MX servers. And I convert it to a alias.cdb file.
> -----Original Message----- > From: Ajay Nawani [mailto:[EMAIL PROTECTED] > Sent: Sunday, August 27, 2006 3:52 AM > To: [EMAIL PROTECTED] Org > Subject: RE: SPAM Control and qmail-ldap proxy. > > Dear Daniel, > > Thanks for the response. > > Do you have any user check script for ldap which can be used in > linuxmagic? > > Ajay Nawani > > -----Original Message----- > From: Daniel Northam [mailto:[EMAIL PROTECTED] > Sent: Sunday, August 27, 2006 12:40 AM > To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Org > Subject: RE: SPAM Control and qmail-ldap proxy. > > > I use linux magic; easy to integrate with qmail, works great; I had the > same issue your having. On my MX I am using > QMAIL+SPAMASSASIN+CLAMAV+linuxmagic > > http://www.linuxmagic.com/opensource/magicmail/magic-smtpd/ > > > > > -----Original Message----- > > From: Ajay Nawani [mailto:[EMAIL PROTECTED] > > Sent: Friday, August 25, 2006 11:18 PM > > To: [EMAIL PROTECTED] Org > > Subject: SPAM Control and qmail-ldap proxy. > > > > Dear Experts, > > > > Request you all to help me on below: > > > > My Setup: > > > > Incoming MX Server: Redhat Linux, Qmail and mail getting forwarded to > > MailStore Server (POP3): Solaris, Qmail-LDAP, Courier-IMAP. > > Outgoing SMTP: Qmail. > > > > Problem: > > > > 1. I'm looking for a solution which can directly drop smtp session at > MX > > Server if user is not exist. Means a Qmail-ldap proxy kind of thing. > > 2. Proper Rate Limit and Spam solution. I get almost 50k mails and out > of > > that 75% are spam. > > > > It will be great if anyone can help me out on above. > > > > Thanks in advance! > > > > Byebye > > > > Ajay Nawani > >
check-user.pl
Description: check-user.pl
#!/usr/bin/perl
#
# Creates sendmail forward compatible .cdb file from
# Active Directory mail attributes. Uses wildcards to capture
# all local domains.
#
# Created by Daniel Northam ([EMAIL PROTECTED])
#
use strict;
use Net::LDAP;
# Gather information about your Active Directory Servers;
my $ldapserver = 'IPADDRESS || HOSTNAME';
my $ldapserver2 = 'IPADDRESS || HOSTNAME';
# I created a power user on each of the Active Directory servers.
# One server is on East Coast the other is on West Coast
# we are the main entry point for email.
my $userToAuthenticate = "cn=LDAP USER,dc=sub-domain,dc=domain,dc=net";
my $userToAuthenticate2 = "cn=LDAP USER,dc=sub-domain,dc=domain,dc=net";
my $passwd = 'password';
my $passwd2 = 'password';
my $base = "dc=sub-domain1,dc=domain,dc=net";
my $base2 = "dc=sub-domain2,dc=domain,dc=net";
my $searchString = "CN=*";
my $domain1 = 'domain1';
my $domain2 = 'domain2';
my $index; # used later to keep track of already used emails.
# If you want to write to a file
my $wfile = '/tmp/file.txt';
open(WFILE, ">$wfile") || die("unable to open file: $!");
# Connect up
my $ldap = Net::LDAP->new("$ldapserver") || die("$@");
my $ldap2 = Net::LDAP->new("$ldapserver2") || die("$@");
$ldap->bind( "$userToAuthenticate",
password => "$passwd",
version => 3 );
$ldap2->bind( "$userToAuthenticate2",
password => "$passwd2",
version => 3 );
# what we are looking for
my @attrs = ('CN=*','proxyAddresses');
# Grap the results
my $result = LDAPsearch ( $ldap, $searchString,[EMAIL PROTECTED], $base );
my $result2 = LDAPsearch ( $ldap2, $searchString,[EMAIL PROTECTED], $base2 );
# Start parsing results.
# process 1st Active Directory Server
my @entries = "";
@entries = $result->entries;
do_work($domain1,@entries);
# Process 2nd Active Directory Server
@entries = "";
@entries = $result2->entries;
do_work($domain2,@entries);
print "finished\n";
close WFILE;
# here is where most of the work is done;
sub do_work {
my ($domain,@entries) = @_; # what sub-domain are we working with,
and the results
foreach my $entr (@entries) {
foreach my $attr ( sort $entr->attributes ) {
my @aliases = ""; #each user will have a primary, rest
will be aliases
my $primary = ""; # primary is where mail is routed to
based on sub-domain
# mail is routed with smtproutes. east
coast/ west coast
if(!($attr =~ m/proxyAddresses/)) { #make sure no other
attribute was grabbed
#do nothing;
}elsif($attr =~ m/X400/) { # we are only dealing
with smtp protocol here
#do nothing;
}else{
my @attribute_list;
push @attribute_list, $entr->get_value($attr);
foreach (@attribute_list) {
if($_ =~ m/;/) { # more checks
#do nothing;
}elsif($_ =~ m/smtp:/) { #
lowercase{smtp} = alias (MS AD standard)
substr($_, 0, 5)="";
my @tmp = split(/\@/, $_);
my $alias = lc("$tmp[0]");
if (!($index =~ m/$alias/)) {
push @aliases, $alias;
# if not found in index, add it to alias
# list for this user.
$index .= "$alias";
# append index, so to not duplicate list;
}
}elsif($_ =~ m/SMTP:/) {
#uppercase{SMTP} this is our primary
#there is only one, so no need to index it
substr($_, 0, 5)="";
my @tmp1 = split(/\@/, $_);
$primary = lc("$tmp1[0]");
print WFILE "$primary : [EMAIL
PROTECTED]"; #make this the first on the list
}
}
foreach (@aliases) { # Now lets print the Alias list
if the alias doesn't match the primary
if($_ =~ m/$primary/i) { # make sure the alias
doesn't match the primary since we are using
# wildcards for the
cdb file.
#do nothing;
}elsif($_ eq "") { #make sure its not empty
#do nothing;
}else{
print WFILE "$_ : [EMAIL PROTECTED]";
}
}
#print "\#----------------------------\n"; #uncomment
if you want to seperate your users.
}
}
}
}
# self explanatory
sub LDAPsearch {
my ($ldap,$searchString,$attrs,$base) = @_;
my $result = $ldap->search ( base => "$base",
scope => "sub",
filter => "$searchString",
attrs => $attrs
);
}
`scp $wfile [EMAIL PROTECTED]:/etc/aliases`;
`ssh [EMAIL PROTECTED] newaliases`;
`scp $wfile [EMAIL PROTECTED]:/etc/aliases`;
`ssh [EMAIL PROTECTED] newaliases`;
`scp $wfile [EMAIL PROTECTED]:/etc/aliases`;
`ssh [EMAIL PROTECTED] newaliases`;
