I'm trying to connect to an LDAP server and run a simple search. I'm getting 'I/O Error' back from my search() call.

The code is:

#!/usr/local/bin/perl use strict; use warnings; use Authen::SASL; use Net::LDAP; my $username = 'dvl'; # Search for the user entry my $filter = "(&(objectClass=person)(CN=$username))"; my $base = "OU=People,DC=us,DC=example,DC=com"; my $dc = "dc.us.example.com"; my $sasl = Authen::SASL->new( mechanism => 'GSSAPI', debug => 1 ) or d +ie 'failed to create sasl'; my $ldap = Net::LDAP->new($dc, port => 636, scheme => 'ldaps') or die +"$@"; my $dse = $ldap->root_dse; die "Can't support GSSAPI" unless $dse->supported_sasl_mechanism('GSSA +PI'); my $mesg = $ldap->bind( 'sasl' => $sasl, version => 3 ) or die "$@"; die 'Error ' . $mesg->code . ': ' . $mesg->error if $mesg->code; if($mesg->is_error()) { die "Failed to set version: " . $mesg->error() . "\n"; } print "searching with filter='$filter' and base='$base'\n"; $mesg = $ldap->search(base => $base, filter => $filter); if($mesg->is_error()) { die "Failed to retrieve user entry: " . $mesg->error() . ' ' . $me +sg->error_name() . ' ' . $mesg->error_desc() . ' ' . $mesg->code . ' + ' . $mesg->mesg_id ( ) . "\n"; } if($mesg->entries == 0) { die "No records found for user '$username'\n"; } $ldap->done();

The output I get is:

$ perl testing.pl state(0): continuation call to routine required;unknown mech-code 0 fo +r mech unknown; output token sz: 1514 state(0): Function completed successfully;unknown mech-code 0 for mec +h unknown; output token sz: state(1): layermask 7,rsz 10485760,lsz 16777215,choice 4 searching with filter='(&(objectClass=person)(CN=dvl))' and base='OU=P +eople,DC=us,DC=example,DC=com' Failed to retrieve user entry: I/O Error LDAP_OPERATIONS_ERROR Operat +ions error 1 5

I've tried various values for filter; all result in the same LDAP_OPERATIONS_ERROR error. Suggestions please?


In reply to Net::LDAP giving I/O Error by dvl

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.