Re: Search and print unique LDAP attribute values.

Bruce Johnson <[email protected]> Fri, 14 Sep 2012 09:41:50 -0700
Newsgroups gmane.comp.lang.perl.modules.ldap
Message-ID <[email protected]>
On Sep 14, 2012, at 9:38 AM, Chris Ridd wrote:

> 
> On 14 Sep 2012, at 16:46, Bruce Johnson <[email protected]> wrote:
> 
>> 
>> On Sep 14, 2012, at 12:13 AM, Chris Ridd wrote:
>>> 
>>> By definition the values in a given stored LDAP attribute have to be all unique, so most of your problem "goes away": @result is simply @a!
>> 
>> I'm pretty sure that the method here will only work with single-valued attributes.
> 
> It'll work just fine with multi-valued attributes - the trick is that you have to call get_value in an array context, and then it'll return an array of all the values. Otherwise it'll just return one of them.
> 
> See <http://search.cpan.org/~gbarr/perl-ldap-0.4001/lib/Net/LDAP/Entry.pod#get_value>
> 
> I usually use it something like this:
> 
> my (@vals) = $entry->get_value("objectClass");
> foreach my $val (@vals) {
>   ...
> }

cool, that's simpler than the as_struct method.


-- 
Bruce Johnson
University of Arizona
College of Pharmacy
Information Technology Group

Institutions do not have opinions, merely customs