Hi out there,
I tried out to get our users in Active DIrectory for configuring postfix
with the help of a perl-script.
I installed Net::LDAP without any Problems.
But when I want to execute my Script I got "Error:49".
I have no experience with Perl, i just copied a Script I found for my
problem.
I didn't find anything about "Error:49" in google, so i hope that you
can help.
Here is the Script:
#!/usr/bin/perl5.8.5 -T -w
use Net::LDAP;
use Net::LDAP::Control::Paged;
use Net::LDAP::Constant ( "LDAP_CONTROL_PAGED" );
# Enter the path/file for the output
$VALID = "/etc/postfix/exchange_recipients";
# Enter the FQDN of your Active Directory domain controllers below
$dc1="192.168.10.15";
$hqbase="dc=bremen, dc=abat, dc=de";
# Note: You can also use the UPN login: "[EMAIL PROTECTED]"
$user="[EMAIL PROTECTED]";
$passwd="MyPassword";
# Connecting to Active Directory domain controllers
$ldap = Net::LDAP->new ($dc1) or die "$@";
$mesg = $ldap->bind ( dn => $user,
password =>$passwd);
if ( $mesg->code()) {
die ("error:", $mesg->code(),"\n");
}
$page = Net::LDAP::Control::Paged->new( size => 990 );
@args = ( base => $hqbase,
filter => "(& (mailnickname=*) (| (&(objectCategory=person)
(objectClass=user)(!(homeMDB=*))(!(msExchHomeServerName=*)))
(&(objectCategory=person)(objectClass=user)(|(homeMDB=*)
(msExchHomeServerName=*)))(&(objectCategory=person)(objectClass=contact))
(objectCategory=group)(objectCategory=publicFolder) ))",
control => [ $page ],
attrs => "proxyAddresses",
);
my $cookie;
while(1) {
# Perform search
my $mesg = $ldap->search( @args );
# Filtering results for proxyAddresses attributes
foreach my $entry ( $mesg->entries ) {
my $name = $entry->get_value( "cn" );
# LDAP Attributes are multi-valued, so we have to print each one.
foreach my $mail ( $entry->get_value( "proxyAddresses" ) ) {
if ( $mail =~ s/^(smtp|SMTP)://gs ) {
push(@valid, $mail." OK\n");
}
}
}
# Only continue on LDAP_SUCCESS
$mesg->code and last;
# Get cookie from paged control
my($resp) = $mesg->control( LDAP_CONTROL_PAGED ) or last;
$cookie = $resp->cookie or last;
# Set cookie in paged control
$page->cookie($cookie);
}
if ($cookie) {
# We had an abnormal exit, so let the server know we do not want any more
$page->cookie($cookie);
$page->size(0);
$ldap->search( @args );
# Also would be a good idea to die unhappily and inform OP at this point
die("LDAP query unsuccessful");
}
# Only write the file once the query is successful
open VALID, ">$VALID" or die "CANNOT OPEN $VALID $!";
print VALID @valid;
close VALID;
Thanks for your help :-)
greetz,
Tanja