[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
Re: Perl LDAP where for help?
Gary,
On Mon, Dec 01, 2003 at 02:46:38PM -0600, Gary Allen Vollink wrote:
> The LDAP libs seem happy to return an entry, but will only return the
> first value in a multi-valued pair. "ou" specifically, is loaded with a
> few gems that I need to get to.
I wrote an introductory article to perl-ldap, that was published on
Linux Journal's website earlier this year:
http://www.linuxjournal.com/article.php?sid=7086
To get all the values for a multivalued attribute, you have to ask for
them in an array context ( eg, @array = $entry->get_value("ou"); )
Quick overview of what you have to do, without any error checking or
accounting for my lack of sleep:
#===========================================================================
$ldap = Net::LDAP->new("server.wherever.com");
$ldap->bind("cn=your bind dn,dc=whatever",password=>"secret");
$mesg = $ldap->search(filter=>"uid=whoever",base=>"dc=whatever");
# Let's assume the first entry is the one we want. Not good for
# real life situations.
$entry = $mesg->entry(0);
# To get all values for a multi-valued attribute, ask for it in
# an array context
@ou = $entry->get_value("ou");
#===========================================================================
Hope that helps,
Paul.
--
Paul Dwerryhouse | PGP Key ID:
Amsterdam, The Netherlands (X) <-> Melbourne, Australia ( ) | 0x6B91B584