问题
I've a little issue. At work, we will shortly use a proxy ldap to connect to our ldap.
However, my perl script used to connect directly to the ldap, and I can't find the right way to connect to the ldap through the ldap proxy.
The ldap team told me to simply change "my.local.ldap.org" by the url of the proxy.
But when I do that, I get nothing back except the error "Can't contact LDAP server at myscript.pl line X, < DATA> line 403."
I'm at my wits end, since I'm pretty new to perl.
How can I connect to my ldap throught the ldap proxy and get my data ?
There is my perl code :
#!/usr/bin/perl
use warnings;
use strict;
use Net::LDAP;
use Net::SMTP;
use MIME::Lite;
use Getopt::Std;
connect_ldap();
sub connect_ldap {
my @attributs = qw(uid subsidiary preferredLanguage);
my $ldap = Net::LDAP->new(
"my.local.ldap.org",
port => 389
) or die open (STDERR, ">&SDTOUT");
my $mesg = $ldap->bind (
"cn=app_readonly,ou=account,ou=security,o=oubase",
password => "mypassword"
);
$mesg = $ldap->search(
base => "o=oubase",
scope => "sub",
filter => "(&(objectclass=inetOrgPerson)(|(subsidiary=sub1)(subsidiary=sub2))(role=id=app_access,id=APP,*))",
attrs => [ @attributs ]
);
printf "COUNT : %s\n", $mesg->count;
foreach my $entry ($mesg->entries) {
$entry->dump;
}
print "==========================================\n";
$mesg = $ldap->unbind;
$ldap->unbind;
}
回答1:
In general, there should not be any difference connecting through a proxy (provided that it is an LDAP proxy) compared to connecting to an LDAP server directly as long as the LDAP proxy is setup properly. Did you try telnetting to the host/port of the proxy to see if you got the correct connection information?
来源:https://stackoverflow.com/questions/41058182/how-to-connect-to-a-ldap-through-a-proxy-ldap