How to connect to a ldap through a proxy ldap?

梦想与她 提交于 2020-04-19 05:45:30

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!