sendmail to exchange w/ldap problem slightly OT

Steven Andrews sandrews at andrewscompanies.com
Tue Nov 4 13:58:06 GMT 2008


I've been using a hunk of code to have MS/Sendmail query exchange
2000/2003 boxes for some time with no problems.  Today, I'm setting up a
nice little dell R200 and so I had to use Centos4.7 over my default 4.3
to get sata support.  

 

Any help, much appreciated...

 

When I run the code, I get this silliness:

 

[root at spamfilter mail]# ./sendmail-ldap.sh

Name "main::EMAILS" used only once: possible typo at ./sendmail-ldap.sh
line 57, <DATA> line 275.

Name "main::DOMAINS" used only once: possible typo at ./sendmail-ldap.sh
line 60, <DATA> line 275.

starting ./sendmail-ldap.sh at Tue Nov  4 08:55:00 EST 2008

Undefined subroutine &main::extract_emails called at ./sendmail-ldap.sh
line 51, <DATA> line 466.

[root at spamfilter mail]#

  

 

Code here:

#!/usr/bin/perl -w

 

use strict;

use Net::LDAP;

 

print "starting $0 at ", `date`;

 

my $debug = 0;

my %mails = ();

my $hostname = `hostname -f`;

chomp $hostname;

my %domains = ($hostname => 1);

my $dir = "/etc/mail";

 

my $emails_file = "$dir/temp-emails";

my $domains_file = "$dir/temp-domains";

my $access_file = "$dir/access";

my @prefixes = ("postmaster", "abuse", "root");

my @servers =

(     "mail.boogidy.com"

);

 

sub extract_emails($);

 

my $ldap = undef;

my $mesg = undef;

 

for my $server (@servers)

{       print STDERR "Connecting to server $server...\n" if $debug;

        $ldap = Net::LDAP->new( $server ) and last;

}

 

$ldap or die "Unable to connect to any LDAP servers.";

 

print STDERR "Binding...\n" if $debug;

$mesg = $ldap->bind(

        dn => 'BOOGIDY\Administrator',

        password => 'redacted'

) or die "Could not bind LDAP: $@";

 

$mesg->code and die $mesg->error;

 

print STDERR "Searching...\n" if $debug;

$mesg = $ldap->search(

        base   => "dc=boogidy,dc=local",

        filter =>
"(|(objectClass=publicFolder)(&(sAMAccountName=*)(mail=*)))"

);

 

print STDERR "Checking code...\n" if $debug;

$mesg->code and die $mesg->error;

extract_emails($mesg);

 

print STDERR "Unbinding...\n" if $debug;

$mesg = $ldap->unbind;   # take down session

 

open EMAILS, "> $emails_file"

        or die("Could not open > $emails_file\n$!");

 

open DOMAINS, "> $domains_file"

        or die("Could not open > $domains_file\n$!");

 

open ACCESS, "> $access_file"

        or die("Could not open > $access_file\n$!");

 

print ACCESS << "END";

##############################################################

#

# This access database is generated by $0

#

# This is regenerated by a cron job

# Any change you make will be wiped out!

#

##############################################################

 

# Check the /usr/share/doc/sendmail/README.cf file for a description

# of the format of this file. (search for access_db in that file)

# The /usr/share/doc/sendmail/README.cf is part of the sendmail-doc

# package.

#

# by default we allow relaying from localhost...

Connect:localhost               RELAY

Connect:127.0.0.1               RELAY

GreetPause:127.0.0.1       0

ClientConn:127.0.0.1       0

ClientConn:                10

 

END

 

Steven R. Andrews, President 
Andrews Companies Incorporated 
Small Business Information Technology Consultants 
sandrews at andrewscompanies.com 
Phone: 317.536.1807

"If your only tool is a hammer, every problem looks like a nail." 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.mailscanner.info/pipermail/mailscanner/attachments/20081104/8d147178/attachment.html


More information about the MailScanner mailing list