in reply to Is there a better solution: data from Net::LDAP?

Hi Mick,

Besides me recommending that you use strict I notice that in your main loop you have a completely unnecessary flip flop from individual scalars to 1 scalar and back again (join then split on lines 15 && 16)

It also that there are better methods to use in the wonders that are Net::LDAP (like entries to avoid the $max stuff). Are you using the most recent version? This is the documentation I'm using. Unfortunately I don't have an LDAP server to test against so the best test I can do is a perl -c which I can't do because ppm can't find the ppd from Activestate (grr windows).

Here's my shot:

use Net::LDAP; use strict; my $id ='1234'; my $ldap = Net::LDAP->new('host','port') or die "$@"; $ldap->bind; my $mesg = $ldap->search (base => $base, filter => "employee_number=$id", attrs => [firstname,lastname,employee_number,department,ci +ty]); my %userinfo; foreach my $entry ($mesg->entries){ foreach my $attr ($entry->attributes){ $userinfo{$attr} = $entry->get($attr); } #$entry->dump; # saw it in the examples but no docs! } # test the hash... foreach my $attr (keys %userinfo){ print "$attr\t$userinfo{$attr}\n"; } $ldap->unbind;

I saw where in the documentation you got your example but I think this works a little more efficiently (if it works at all)

Sorry about the lack of testing, normally I wouldn't do this (post untested code).

--
Clayton
Long time reader, first time poster.