According to the Net::LDAP documentation:

new ( HOST, OPTIONS )

HOST may also be a reference to an array of hosts, host-port pairs or URIs to try. Each will be tried in order until a connection is made. Only when all have failed will the result of undef be returned.


However, this doesn't seem to be the case.  I have the following code:

 my $ldap_url = getLocalConfig("ldap_url");
 print STDOUT "LDAP URL is $ldap_url\n";
 my @ldap_url = split / /, $ldap_url;
 foreach my $url (@ldap_url) {
    print STDOUT "Array: $url\n";
 }
 $ldap_url = [EMAIL PROTECTED];
 print "LDAP URL is now $ldap_url\n";
 $ldap=Net::LDAP->new("$ldap_url");
 if ( $ldap_starttls_supported ) {
   $mesg = $ldap->start_tls(
         verify => 'require',
         capath => "/opt/zimbra/conf/ca",
         ) or die "start_tls: $@";

   $mesg->code && die "TLS: " . $mesg->error . "\n";
 }


With the output, we see that it (a) gets the string value, then (b) splits it correctly into two values in the array, and then (c) it gets set to an array reference. However, we can also clearly see that ldap->new

LDAP URL is ldap://tribes.lab.zimbra.com:389 ldap://freelancer.lab.zimbra.com:389
Array: ldap://tribes.lab.zimbra.com:389
Array: ldap://freelancer.lab.zimbra.com:389
LDAP URL is now ARRAY(0x1a3752c0)
Can't call method "start_tls" on an undefined value at ./zmpostfixpolicyd line 39, <STDIN> line 3.


I never see any connection come to tribes.lab.zimbra.com from the script, so it didn't do anything as far as connection.

Now, if I switch back to just a single URI, things work just fine:

[EMAIL PROTECTED] libexec]$ ./zmpostfixpolicyd -v
request=smtpd_access_policy
[EMAIL PROTECTED]

LDAP URL is ldap://freelancer.lab.zimbra.com:389
action=reject 5.1.1 Mailbox unavailable


So, is Net::LDAP broken, the documentation wrong, or am I missing something?

Thanks,
Quanah

--

Quanah Gibson-Mount
Principal Software Engineer
Zimbra, Inc
--------------------
Zimbra ::  the leader in open source messaging and collaboration

Reply via email to