Skip Menu |

This queue is for tickets about the perl-ldap CPAN distribution.

Report information
The Basics
Id: 121402
Status: rejected
Priority: 0/
Queue: perl-ldap

People
Owner: Nobody in particular
Requestors: fredrik.lysen [...] uadm.uu.se
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



CC: Fredrik Lysén <fredrik.lysen [...] uadm.uu.se>
Subject: Net::LDAP and array
Date: Wed, 26 Apr 2017 14:57:20 +0000
To: "bug-perl-ldap [...] rt.cpan.org" <bug-perl-ldap [...] rt.cpan.org>
From: Fredrik Lysén <fredrik.lysen [...] uadm.uu.se>
perl -v This is perl 5, version 22, subversion 1 (v5.22.1) built for x86_64-linux-gnu-thread-multi (with 58 registered patches, see perl -V for more detail) uname -a Linux its-048568 4.8.0-45-generic #48~16.04.1-Ubuntu SMP Fri Mar 24 12:46:56 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux Show quoted text
________________________________________________________________________ When search AD and receive the attrib "members" I expect to get the list of members in an array so I can do a "foreach... {....}". But I just get all members in the same position [0]. Is this the correct behavior? Best regards Fredrik
________________________________________________________________________ my $result = $ldap->search( base => "OU=ITSD,OU=Groups,OU=Core,DC=nnnn,DC=nn,DC=nn", scope => "sub", filter => "($serach_string)", attributes => ['member'], ); printf "COUNT: %s\n", $result->count; my @entries = $result->entries; foreach my $entr ( @entries ) { print $entr->get_value("member"); }
________________________________________________________________________
RT-Send-CC: fredrik.lysen [...] uadm.uu.se
Hi, On Wed Apr 26 11:06:53 2017, fredrik.lysen@uadm.uu.se wrote: Show quoted text
> When search AD and receive the attrib "members" I expect to get the > list of members in an array so I can do a "foreach... {....}". But I > just get all members in the same position [0]. > Is this the correct behavior? > > my $result = $ldap->search( > base => "OU=ITSD,OU=Groups,OU=Core,DC=nnnn,DC=nn,DC=nn", > scope => "sub", > filter => "($serach_string)", > attributes => ['member'], > ); > > printf "COUNT: %s\n", $result->count; > > my @entries = $result->entries; > > foreach my $entr ( @entries ) { > print $entr->get_value("member"); > }
See the Net::LDAP::Entry man page: When called in list mode, Net::LDAP::Entry's get_value() method does exactly what you expect. When called in scalar mode, it returns the first element. Change your code to somthing like foreach my $entr ( @entries ) { my @members = $entr->get_value("member"); print join("\n", @members)."\n"; } to get the expected result. Closing as it is not a perl-ldap bug.