Net::LDAP

W

Warrick FitzGerald

Hi All,

I have created a user in OpenLDAP which has a password set.

I'd like to bind to the LDAP server as this user using Net::LDAP, but
I'm having some problems figuring out if my bind was sucessful or not.

=========
use Net::LDAP;
$ldap = Net::LDAP->new( '10.10.40.40' );

# bind to a directory with dn and password
$mesg = $ldap->bind( 'uid=sporter,ou=People,dc=livetechnology,dc=com',
password => 'xxxxx'
);

print $mesg."\n";
=========

Returns

Net::LDAP::Bind=HASH(0x8069c24)

but I get this response no matter what password I use ....

How can I tell if this is working or not? All I really want to see is if
this username and password combination works.


Thanks
Warrick
 
M

Mark Clements

Warrick FitzGerald wrote:
use Net::LDAP;
$ldap = Net::LDAP->new( '10.10.40.40' );

# bind to a directory with dn and password
$mesg = $ldap->bind( 'uid=sporter,ou=People,dc=livetechnology,dc=com',
password => 'xxxxx'
);

print $mesg."\n";
=========

Returns

Net::LDAP::Bind=HASH(0x8069c24)

but I get this response no matter what password I use ....

How can I tell if this is working or not? All I really want to see is if
this username and password combination works.


check out

perldoc Net::LDAP::Message

you want to do something like:

if($mesg->is_error()){
my $errorMessage = $mesg->error();
# process failure
}

don't forget to run with

use strict;
use warnings;

Mark
 
A

axel

Warrick FitzGerald said:
I have created a user in OpenLDAP which has a password set.
I'd like to bind to the LDAP server as this user using Net::LDAP, but
I'm having some problems figuring out if my bind was sucessful or not.
=========
use Net::LDAP;
$ldap = Net::LDAP->new( '10.10.40.40' );

# bind to a directory with dn and password
$mesg = $ldap->bind( 'uid=sporter,ou=People,dc=livetechnology,dc=com',
password => 'xxxxx'
);
print $mesg."\n";
=========
Returns
Net::LDAP::Bind=HASH(0x8069c24)
but I get this response no matter what password I use ....
How can I tell if this is working or not? All I really want to see is if
this username and password combination works.

You need to check $mesg->code. If this is non-zero then there is an
error and there should be a message in $mesg->error, e.g.

die $mesg->error if $mesg->code;

Axel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top