Help LDAP connectivity

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Hello, I hope somebody can help me,

I have this program that is listed below that searches an ldap server
for parameters passed on the command line.

It does work but it doesn't skip binary data that is also returned (in
this case jpeg images). I thought that adding the below line would do
the trick, but it doesn't seem to. Maybe I am doing something wrong.

next if ( $entry =~ /;binary$/ );

Can anybody help


use Net::LDAP;

$server = $ARGV[0];
$port   = getservbyname("ldap","tcp") || "389";
$basedn = "ou=staff,dc=somewhere,dc=co,dc=uk";
$scope  = "sub";

$c = new Net::LDAP($server, port=>$port) or
    die "Unable to connect to $server: $@\n";
$c->bind(  ) or die "Unable to bind: $@\n"; # anonymous bind

$searchobj = $c->search(base => $basedn, scope => $scope,
                        filter => $ARGV[1]);
die "Bad search, errorcode #".$searchobj->code() if $searchobj->code(

@entries = $searchobj->entries;

foreach $entry (@entries) {
    next if ( $entry =~ /;binary$/ );

Re: Help LDAP connectivity wrote:
Quoted text here. Click to load it

Take a look at the value of $entry.  It seems that it's not the value
you think it is.


entries ( )

     Return an array of Net::LDAP::Entry objects that were returned from
the server.

Re: Help LDAP connectivity

Ok, you are right.

If i do


i get


Which is very different from what I expected.

I have tried printing some of the other variables too.


which returns

I think I am not entirely understanding what is going on.

I think i'll go read up on Net::LDAP::Entry


Re: Help LDAP connectivity

Hmmmm, maybe I should find another way of doing this.

CPAN Says:

dump ( [ FILEHANDLE ] )

    Dump the entry to the given filehandle.

    This method is intended for debugging purposes and does not treat
binary attributes specially.

Re: Help LDAP connectivity

Quoted text here. Click to load it

Who is right? Please provide some context when you post replies.
Quoted text here. Click to load it

If $entry refers to an object of type Net::LDAP::Entry, then you should
be able to use the interface provided by that object to access the

Quoted text here. Click to load it

Good idea. You should have done it sooner:

The synopsis in the manual page shows you how to access the attributes of an
Net::LDAP::Entry object:

(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:

Site Timeline