mrmick has asked for the wisdom of the Perl Monks concerning the following question:
I have looked at the documentation with Net::LDAP and have been able to come up with the following solution so far. This seems kind of clunky to me and I would really like to find a better way to use the information returned from the LDAP search.
use Net::LDAP; $id='1234'; $ldap = Net::LDAP->new($host,$port) or die "$@"; $ldap->bind; $mesg = $ldap->search (base => $base, filter => "employee_number=$id", attrs => [firstname,lastname,employee_number,department,ci +ty]); my $max = $mesg->count; # put into a local hash for later use... for($i=0;$i<$max;$i++){ my $entry = $mesg->entry($i); foreach my $attr($entry->attributes){ my $printstring = join("\| ",$attr, $entry->get($attr)); my ($attrkey,$attrvalue) = split(/\|/,$printstring); $userinfo{$attrkey}=$attrvalue; } } # test the hash... foreach $key(keys %userinfo){ print "$key\t $userinfo{$key}\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Is there a better solution: data from Net::LDAP?
by clscott (Friar) on Nov 24, 2000 at 08:59 UTC | |
|
Re: Is there a better solution: data from Net::LDAP?
by ChOas (Curate) on Nov 23, 2000 at 17:10 UTC | |
by mrmick (Curate) on Nov 23, 2000 at 19:23 UTC | |
by ChOas (Curate) on Nov 23, 2000 at 19:30 UTC |