Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Net::LDAP->new connection timed out

50 views
Skip to first unread message

noemie....@bluewin.ch

unread,
Jul 6, 2009, 7:36:23 PM7/6/09
to perl...@perl.org
Hi All,

I'm a beginner in Unix and LDAP and I have to create a LDAP directory to store information. I have a ldap server on a
machine which works (I can make queries, adding entries on the LDAP, ...) Now, I try to connect another machine to this
LDAP server via a script Perl. Here is my script (very basic to begin)

-----------------------------------------------------------------------------------------------------------------------------

#!/usr/bin/perl -w

use strict;

use Net::LDAP;

my $ldapHost = "XXXX";

my $user = "XXXX";

my $pw = "XXXX";

my $ldap = Net::LDAP->new($ldapHost, timeout=>240) or die "Can't bind to ldap: $!\n$@\n";

print "NEW\n";

$ldap->bind(dn=>$user, password=>$pw);

print "BIND\n";

$ldap->unbind;

print "---------end-----------\n";

-----------------------------------------------------------------------------------------------------------------------------

My ldapHost is reachable from the client (A ping gives an answer)

In this state, the answer of the script is :

Can't bind to ldap: Connection timed out

IO::Socket::INET: connect: Connection timed out

without timeout specified on Net::LDAP->new, the answer is :

Can't bind to ldap: Operation now in progress

IO::Socket::INET: connect: timeout

I also noticed that a query on the LDAP server takes a long time (Almost one minute for a simple ldapsearch query) Is
it normal? or is it linked with my problem?

As I said before, I'm a really beginner. Feel free to ask if you need more information.

I hope somebody will have a solution or help for me

Thank you

Noemie

Dieter Kluenter

unread,
Jul 7, 2009, 3:03:07 AM7/7/09
to perl...@perl.org
Hi,

"noemie....@bluewin.ch" <noemie....@bluewin.ch> writes:

> Hi All,
>
> I'm a beginner in Unix and LDAP and I have to create a LDAP directory
> to store information. I have a ldap server on a machine which works (I
> can make queries, adding entries on the LDAP, ...) Now, I try to
> connect another machine to this LDAP server via a script Perl. Here is
> my script (very basic to begin)

The most imported information is not given :-(

> #!/usr/bin/perl -w
> use strict;
> use Net::LDAP;
> my $ldapHost = "XXXX";

What is the value of ldapHopst? This should be either a fully
qualified domain name, a URL according to RFC 4516 or an IP-Adress,
whatever you define it has to be resolvable.

> my $user = "XXXX";

What is the value of user? As you do a simple bind, this has to be a
distinguished name.

> my $pw = "XXXX";

Same question here. Do you present clear text or a hashed value?


> my $ldap = Net::LDAP->new($ldapHost, timeout=>240) or die "Can't bind
> to ldap: $!\n$@\n";
> print "NEW\n";
> $ldap->bind(dn=>$user, password=>$pw);
> print "BIND\n";
> $ldap->unbind;
> print "---------end-----------\n";
>

> My ldapHost is reachable from the client (A ping gives an answer)

Ping is not relevant here, can you reach port 389 on this host? There
are probably firewall rules to prevent connenction on ldap port

[...]


> I also noticed that a query on the LDAP server takes a long time
> (Almost one minute for a simple ldapsearch query) Is it normal? or is
> it linked with my problem?

This depends on the settings for client timeout.

> As I said before, I'm a really beginner. Feel free to ask if you need
> more information.
>
> I hope somebody will have a solution or help for me

Your questions are more ldap related and not specific to perl-ldap,
asking on a ldap specific mailing list would be more appropriate.

-Dieter

--
Dieter Klünter | Systemberatung
http://dkluenter.de
GPG Key ID:8EF7B6C6
53°08'09,95"N
10°08'02,42"E

0 new messages