Anonymous searches fail with 'invalid DN'

Prentice Bisbal <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.ldap
Message-ID <[email protected]>
In a subsequent section of the same search, I'm trying to do an
anonymous search. Anonymous binding works (or more accurately, doesn't
produce an error code). Hoever, when I do search using the same LDAP
handle, I get an error. I know anonymous searching is allowed, and I can
verify this using ldapsearch.

My code for the bind/search is below. Am I doing something wrong? This
code is almost identical to the first example code on
http://search.cpan.org/~gbarr/perl-ldap-0.40/lib/Net/LDAP.pod

This code works just fine when I run this code with my Kerberos/GSSAPI
credentials, but not after I do a 'kdestroy'

# Anonymous bind (no args = anonymous)
$mesg = $ldap->bind;
$code = $mesg->code;
if ($code == 0) {
 if ($verbose) {
	print "Successfully bound to $hostname\n";
    }
} else {
    $error = $mesg->error;
    print "Error doing an anonymous bind\n";
    print "$error\n";
    $exit_val = '2';
}

# Step 3:
# Perform a search
# If we fail here, exit status = 1
$mesg = $ldap->search(base => $base,
		      filter => "$attr"
		      );
$code = $mesg->code;
if ($code == 0) {
    # Successful doesn't mean we got the results we wanted, though.
    # Search that returns 0 results is still successful in this case
    # We really need to check if any entries were returned for this
    @entries = $mesg->entries;
    $size = @entries;
    if ($size != 0) {
	if ($verbose) {
	    print "LDAP search for $attr successful\n";
	}
    } else {
	print "LDAP search for $attr failed\n";
	$exit_val = '1';
    }
} else {
    $error = $mesg->error;
    print "LDAP search operation failed\n";
    print "$error\n";
    $exit_val = '1';
}

-- 
Prentice
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.