WhyNot87 has asked for the wisdom of the Perl Monks concerning the following question:

Getting the following error every time I run the below script. "No such object at C:\Perl Scripts\ldap.pl line <DATA> line 522", Any ideas?
use Net::LDAP; $ldap = Net::LDAP->new( 'company.ldap.com' ) or die "$@"; $mesg = $ldap->bind ; # an anonymous bind $mesg = $ldap->search( # perform a search base => "ou=corp", filter => "(&(cn=Any User))" ); $mesg->code && die $mesg->error; foreach $entry ($mesg->entries) { $entry->dump; } $mesg = $ldap->unbind; # take down session

Replies are listed 'Best First'.
Re: LDAP Connection
by ww (Archbishop) on Oct 30, 2011 at 13:44 UTC
    1. Line 522 fell off the end of your __DATA__ section?
    2. 522 doesn't contain what your code expects?
    3. Other (but my guesser has run out of steam)

    What does your data look like? A small sample will suffice.

      I think the problem is I have not set the default connection parameters. But would I set those in LDAP.pm? How does it know what port to use if I am not using the default port?
      I'm not quite sure what line 522 is referencing. But I am still researching to find out where I set my default connection parameters. I'm assuming LDAP.pm. Or would I define those parameters in my ldap.pl code? I can't seen to locate a definitive answer...
Re: LDAP Connection
by johnny_carlos (Scribe) on Oct 30, 2011 at 16:24 UTC
    Could it be the query isn't returning any results(no matches)? Have you tried the same query in an LDAP search tool?

    Edit: Also, comment out all your code, then uncomment line-by-line until you figure out exactly which line is causing it :)

      Yeah I tried the same query and got results. I'm about to step through the code now line for line...
        OK now I am getting the below. I think I might start a new thread with this... Can't locate Net/LDAP.pm in @INC (@INC contains: C:/Perl/site/lib .)