in reply to Perl LDAP script error "Can't call method "dn" on an undefined value"

Hi there,

Likely what is happening is that "$mesg" is not receiving valid data back from $ldap->search. You may just have a single bad entry in your test.txt file.

At a minimum you will want to add a line that tests the value of $entry, like so:

my $entry = $mesg->shift_entry(); next unless $entry;

In order to skip over any bad entries in your input text file. Of course you should probably do proper error reporting as well.

To debug this further you can use Data::Dumper and show the return results of the search function. If my guess is correct you will see 'errorMessage => "Bad filter"' in the returned hash:

use Data::Dumper; ... $mesg = $ldap->search ( @args ) or die $!; print Dumper $mesg;
HTH.

Replies are listed 'Best First'.
Re^2: Perl LDAP script error "Can't call method "dn" on an undefined value"
by anakin30 (Acolyte) on Apr 24, 2013 at 09:56 UTC

    Hi Loops,

    Thanks for sharing with me .. i appreciate that a lot.