Re: getting multi-valued attribute?

[email protected] (Phil Lembo)
Newsgroups perl.ldap
Message-ID <[email protected]>
You have to call the attribute in an array context, like this

@values = $entry->get_value('attributename');

where 'attributename', is the name of a multi-valued attribute, like
'telephonenumber'.

Then iterate over the array to pull out the values, eg:

$value(@values) {

     print "attributename", $value, "\n":

}

There are better examples given in the FAQ,
http://search.cpan.org/~gbarr/perl-ldap/lib/Net/LDAP/FAQ.pod, and
Examples, http://search.cpan.org/~gbarr/perl-ldap/lib/Net/LDAP/Examples.pod.

Phil Lembo

On Fri, Dec 18, 2009 at 3:31 PM, Bruce Johnson
<[email protected]> wrote:
> I'm attempting to query our campus enterprise directory LDAP server, and
> it's got one attribute that has multiple entries per person.
>
> This is the code I'm using:
>
> --------------------------------------------------------------------------
> #!/usr/bin/perl
>
> use Net::LDAPS qw(:all);
> use Data::Dumper;
>
> #username and password for new enterprise directory stuff
> $iamlogin = '<redacted>';
> $iampasswd = '<redacted>';
> $searchBase = "ou=People,dc=eds,dc=arizona,dc=edu";
> $searchFilter = "emplID=<redacted>";
> # Connect to LDAPS port
> $ldaps = new Net::LDAPS(
>                '<redacted>',
>                port => 636,
>                capath => '/usr/share/ssl/certs/') or die "Certs problem!
> Cannot connect!\n";
>
> # Bind as NetID user
> $mesg = $ldaps->bind(
>        dn => "uid=$iamlogin,ou=App Users,dc=eds, dc=arizona, dc=edu",
>        password => $iampasswd);
> $mesg->code && die "Authentication failed: " . $mesg->error . "\n";
>
> $mesg = $ldaps->search (  # perform a search
>                               base => $searchBase,
>                               filter => $searchFilter,
>                     attrs => ["*", "+"]
>                          );
>
>                $mesg->code && die $mesg->error;
>
>
> $nums = $mesg->count;
>
> print Dumper($mesg);
> exit;
> --------------------------------------------------------------------------
>
> This works, but returns only one instance of the desired attribute.
>
> How do I get all of them?
>
> --
> Bruce Johnson
> University of Arizona
> College of Pharmacy
> Information Technology Group
>
> Institutions do not have opinions, merely customs
>
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.