Hi, an alternative would be to get the whole structure as a hash. I do the following:
my %href; my ($uid) = @_; $mesg = $ldap->search( # perform a search base => "ou=People,dc=male", filter => "(&(objectClass=posixAccount)(uid=$uid))", ); $mesg->code && die $mesg->error; foreach my $entry ($mesg->entries) { foreach my $attr ($entry->attributes) { $href{"$attr"} = $entry->get_value($attr, asref => 1); } } return \%href
note "asref=>1" as get_value() option. This way I get all values for an attribute, like I get multiple objeckClasses for one objectClass attribute. Having the whole ldap structure is nice, but getting the values out of hash is a bit tricky, use Data::Dumper to see the real picture. This is how I get the values from the hash for an attribute:
sub getattrval { my ($hashref,$attr) = @_; if ( %$ld{$attr} ) { my $tmp_href = %$ld{$attr}; # return comma delimited string instead of array return join (",",@$tmp_href) if scalar @$tmp_href > 1; return @$tmp_href[0]; } return undef; }

In reply to Re: Multiple values per attribute from a Net::LDAP query? by noname
in thread Multiple values per attribute from a Net::LDAP query? by TQuid

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.