Hi monks, I'm working on a CGI program with Net::LDAP to update an OpenLDAP addressbook. I'm not an LDAP expert by any means but I worked with the command line tools so I would understand the basics. I'm having a repeated problem at first I thought I just didn't get it but I keep running into the same error with different chunks of Perl code.
my $ldap = Net::LDAP->new( "$ldap_svr" ) or die "$@"; my $search = $ldap->bind; $search = $ldap->search( base=> "$base", filter=>"mail=$name_email" ); my $max = $search->count; for ( my $index = 0; $index < $max ; $index++ ) { my $entry = $search->entry($index); my $dn = $entry->dn; my @attrs = $entry->attributes; foreach my $var (@attrs) { my $attr = $entry->get_value( $var, asref => 1 ); if ( defined($attr) ) { foreach my $value ( @$attr ) { print h2("$var: $value"),p; } } } } $search= $ldap->unbind;
I get the error:
Can't call method "count" without a package or object reference at c:\PROGRA~1\APACHE~1\apache\cgi-bin\PROCES~2.PL line 126
I was also getting an error before about using $search->entries method. As you can see I'm testing this on a windows XP machine with active state v5.8.2 and apache using perl as a cgi.

TIA,
chrisj


In reply to Net::LDAP issues... by chrisj0

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.