Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Help LDAP connectivity

Reply
Thread Tools

Help LDAP connectivity

 
 
cwoollard@gmail.com
Guest
Posts: n/a
 
      05-12-2005

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

Thanks
chris


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$/ );
$entry->dump;
}

 
Reply With Quote
 
 
 
 
J. Gleixner
Guest
Posts: n/a
 
      05-12-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> 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


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

Hint..

entries ( )

Return an array of Net::LDAP::Entry objects that were returned from
the server.
 
Reply With Quote
 
 
 
 
Chris
Guest
Posts: n/a
 
      05-13-2005
Ok, you are right.

If i do

print("$entry\n");

i get

Net::LDAP::Entry=HASH(0x1c21d5c)

Which is very different from what I expected.

I have tried printing some of the other variables too.

print("@entries\n");

which returns
Net::LDAP::Entry=HASH(0x1c218b4)

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

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

thanks
chris

 
Reply With Quote
 
Chris
Guest
Posts: n/a
 
      05-13-2005
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.

 
Reply With Quote
 
A. Sinan Unur
Guest
Posts: n/a
 
      05-13-2005
"Chris" <(E-Mail Removed)> wrote in news:1115974970.076651.30410
@z14g2000cwz.googlegroups.com:

> Ok, you are right.


Who is right? Please provide some context when you post replies.

> If i do
>
> print("$entry\n");
>
> i get
>
> Net::LDAP::Entry=HASH(0x1c21d5c)
>
> Which is very different from what I expected.


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
fields.

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


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:

http://search.cpan.org/~gbarr/perl-l...LDAP/Entry.pod

--
A. Sinan Unur <(E-Mail Removed)>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/cl...uidelines.html
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
python-ldap/win32 or python/ldap/win32 rcmn Python 1 11-06-2006 11:47 PM
Need to wrtie LDAP class to *answer* LDAP queries. junk1@davidbevan.co.uk Java 1 02-21-2006 09:59 PM
ruby-ldap: uninitialized constant LDAP::LDAP_CONTROL_PAGEDRESULTS James Hughes Ruby 4 12-13-2005 11:46 PM
[ANN] Ruby/LDAP 0.9.1: LDAP API (RFC1823) library. Ian Macdonald Ruby 0 03-15-2005 11:23 PM
using LDAP Controls in ruby-ldap Jason Wold Ruby 5 11-07-2004 03:35 AM



Advertisments