Darren, 

I use something like this, If I see "Past Bind" printed I can be sure
its bound to server, I have been using this for years without problems.

<snip>

#----------------------------
# Directory Connection
#----------------------------

my $hostname="zyz.mydomain.com"
my $port=389;
my $bind_dn="cn=DirectoryManager,OU=Users,DC=mydomain,DC=com";
my $password = "password";
my $base = "OU=Users&Groups,OU=Users,DC=mydomain,DC=com";
my $scope = "one";
my $filter = "(&(objectclass=user)(objectCategory=person)(uid=*))"

# End of connection variables


# Binding

my $ldap = Net::LDAP->new($hostname) || die();
my $bind = $ldap->bind($bind_dn, password=>$password)|| die();

print "Past bind\n";

</snip>

Here if the bind method fails it simply called die () , terminating the
execution of the code.

Regards,
Yash

-----Original Message-----
From: Young, Darren [mailto:[EMAIL PROTECTED] 
Sent: Monday, June 09, 2008 11:45 PM
To: perl-ldap@perl.org
Subject: Check connection

Is there any way to check to see if a Net::LDAP object is
connected/bound to a server?

As in:

$ldap = Net::LDAP->new($server);
$mesg = $ldap->bind($stuff);

if ( $ldap->is_connected($possibly_some_server) ) {
        print("Connected\n");
}

if ( $mesg->is_bound($possibly_with_a_dn) ) {
        Print("Bound\n");
}


etc, etc...

Reply via email to