Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Net::LDAP issue

Status
Not open for further replies.

MoshiachNow

IS-IT--Management
Feb 6, 2002
1,851
0
0
IL
HI,

My following code:

my $ldap = Net::LDAP->new( 'localhost:389' );
# bind to a directory with dn and password
my $mesg = $ldap->bind("cn=ComputersNum , cn=HardwareConfiguration , cn=NeriaAdministration ,
cn=POD_ROOT,CN=POD_Partition , dc=KODAK", user=>'PodLdapUser', password => 'PodLdap123');

Causes the following error:

Can't call method "bind" on an undefined value at D:\DOcuments\myscripts\taskmon.pl line 264, <DATA> line 275.

Will appreciate advise.
thanks


Long live king Moshiach !
 
From the docs,

Code:
 $ldap = Net::LDAP->new( 'ldap.bigfoot.com' ) or die "$@";

Thus is can be implied the new() call will return false or undef on failure. Maybe it can't connect to the host/port you gave it, and returns undef, and thus your object is an undef var later when you call bind() on it.

So make sure the call to new() doesn't return undef.

-------------
Cuvou.com | My personal homepage
Code:
perl -e '$|=$i=1;print" oo\n<|>\n_|_";x:sleep$|;print"\b",$i++%2?"/":"_";goto x;'
 
thanks,

my new code is :

my $ldap = Net::LDAP->new( 'localhost' ) || warn "unable to connect: localhost:389\n";
# bind to a directory with dn and password
my $mesg = $ldap->bind( user=>'xxxxxx', password => 'yyyyyyyy') || warn "Unable to bind\n";
$mesg = $ldap->search( base => "cn=ComputersNum , cn=HardwareConfiguration , cn=NeriaAdministration ,
cn=POD_ROOT, cn=POD_Partition , dc=KODAK" , filter => "sn=POD-Value");
$mesg->code && warn $mesg->error;
foreach my $entry ($mesg->entries) {
print STDOUT "ENTRY=$entry->dump\n";
}

And I get error related to Aurtentication:

000004DC: LdapErr: DSID-0C09062B, comment: In order to perform this operation a
successful bind must be completed on the connection., data 0, vece at script/taskmon.pl line 263, <DATA> line 532.

What can be a problem ? some syntax issue ?
thanks

Long live king Moshiach !
 
Is it related to the port?
or to the packages :
use Net::LDAP;

You should check the integrity of the Net::LDAP package or the port to open.

You should also check that:"cn=xxxx,o=domain.com" or something like that:

my $mesg = $ldap->bind( "cn=xxxx,o=domain.com", password => 'yyyyyyyy') || warn "Unable to bind\n";


Filter first:


$mesg = $ldap->search(filter => "sn=POD-Value", base => "cn=ComputersNum , cn=HardwareConfiguration , cn=NeriaAdministration ,
cn=POD_ROOT, cn=POD_Partition , dc=KODAK");


@entries = $mesg->entries;
foreach $entry (@entries) {
@atts = $entry->attributes();
foreach $att (@atts) {
$entry=$entry->get_value($att);

}
}

 
thanks,

The instructions I got from our programmer were :

Server name =localhost
Port=389
User=xxxxxx
Password=yyyyyy

DN(Distinguished Name)=
CN=ComputersNum,CN=HardwareConfiguration,CN=NeriaAdministration,CN=POD_ROOT,CN=POD_Partition,DC=KODAK
Attribute=POD-Value

So this is all data I got.
From above - anything I should change in my code?
thanks


Long live king Moshiach !
 
HI,

My current new code is :

#Establish exact config
my $LDAP_BASE = 'cn=ComputersNum ,cn=HardwareConfiguration ,cn=NeriaAdministration ,cn=POD_ROOT,cn=POD_Partition';
my $userDN = 'uid=PodLdapUser,dc=KODAK';
my $ldap = Net::LDAP->new( 'localhost', port=>389, debug=>9, onerror => 'warn' ) or die "Unable to connect to LDAP server localhost:389 $@\n";
;
# bind to a directory with dn and password
my $mesg = $ldap->bind( dn=>$userDN , password =>'PodLdap123');
$mesg = $ldap->search(filter => 'sn=POD-Value', base =>$LDAP_BASE);
$mesg->code && warn $mesg->error;
my @entries = $mesg->entries;
foreach my $entry (@entries) {
my @atts = $entry->attributes();
foreach my $att (@atts) {
$entry=$entry->get_value($att);
}
}

The errors are :

Net::LDAP=HASH(0x1f80ccc) sending:

30 2E 02 01 01 60 29 02 01 03 04 18 75 69 64 3D 0....`).....uid=
50 6F 64 4C 64 61 70 55 73 65 72 2C 64 63 3D 4B PodLdapUser,dc=K
4F 44 41 4B 80 0A 50 6F 64 4C 64 61 70 31 32 33 ODAK..PodLdap123

Net::LDAP=HASH(0x1f80ccc) received:
0000 104: SEQUENCE {
0006 1: INTEGER = 1
0009 95: [APPLICATION 1] {
000F 1: ENUM = 49
0012 0: STRING = ''
0014 88: STRING
0016 : 38 30 30 39 30 33 30 34 3A 20 4C 64 61 70 45 72 80090304: LdapEr
0026 : 72 3A 20 44 53 49 44 2D 30 43 30 39 30 33 33 36 r: DSID-0C090336
0036 : 2C 20 63 6F 6D 6D 65 6E 74 3A 20 41 63 63 65 70 , comment: Accep
0046 : 74 53 65 63 75 72 69 74 79 43 6F 6E 74 65 78 74 tSecurityContext
0056 : 20 65 72 72 6F 72 2C 20 64 61 74 61 20 32 30 65 error, data 20e
0066 : 65 2C 20 76 65 63 65 00 __ __ __ __ __ __ __ __ e, vece.
006E : }
006E : }
80090304: LdapErr: DSID-0C090336, comment: AcceptSecurityContext error, data 20ee, vece at script/taskmon.pl line 263
Net::LDAP=HASH(0x1f80ccc) sending:


Need help !!!!!!

Long live king Moshiach !
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top