Sponsored Content
Top Forums Shell Programming and Scripting Perl and Net::LDAP, objects and arrays query Post 302227627 by buffoonix on Thursday 21st of August 2008 04:21:13 PM
Old 08-21-2008
Phew, it's been quite some time since I last played with Net::LDAP.
And as far as I can remember it took quite a bit of reading the POD beforehand.
So I would suggest you revisit the POD because it is all explained there how you access the returned objref of Net::LDAP::Search.
Because I have forgotten almost all I just have had a quick glance at it on search.cpan.org,
Net::LDAP::Search - Object returned by Net::LDAP search method - search.cpan.org
This class offers several accessor methods to fetch the result set.
As you went for the entries() method, this it says returns an array of Net::LDAP::Entry objrefs.
So you would have to look at this class' POD as well to know how to access the data
Net::LDAP::Entry - An LDAP entry object - search.cpan.org
Just from my very superficial exposure to the POD right now I would probably try something like this
(please, note this is a mere wild guess since I haven't even Net::LDAP installed on my surf laptop)
Code:
foreach my $entry ($mesg->entries()) {
    my @vals = grep { /staff|student/ } @{ $entry->get_value('businessCategory', asref => 1) };
    # further process @vals here
}

But please, this is a wild untested guess which probably is horribly wrong.
You just will have to consult the POD.
What I usually do to get a quick view of the deeply nested data structures I am not yet clear about
is to run my code in the Perl debugger (just invoke your script with preceeding perl -d
Then I continue (c) to the line where the result is fetched and view it in my pager by
Code:
DB<3> | x $mesg

This is most of the times far quicker to grasp then perusing the whole POD.
 

10 More Discussions You Might Find Interesting

1. Solaris

New to Perl-LDAP

Hi all I am new to perl-ldap. Trying to install DBD module on sun solaris which has the iplanet51 ldap already installed. I have got the DBD-LDAP-0.03.tar file , and un packed it. From the dir DBD-LDAP-0.03 - i tried to do $ perl Makefile.PL and i got the... (10 Replies)
Discussion started by: kaushi
10 Replies

2. UNIX for Dummies Questions & Answers

LDAP search query help

I would like to do an ldap search which looks for entries which do not actually have a certain attribute. Not that the attribute is Null, but where the attribute does not exist. Is this possible using ldapsearch? (3 Replies)
Discussion started by: dopple
3 Replies

3. Solaris

Net-SNMP v5.4 - sub-id not found in log, but can query with snmpget and snmpwalk

Hi everyone, I'm configuring Net-SNMP v5.4 on Solaris 10, sending traps to OpenNMS 1.2.9-0.20061212.0. I'm setting up disk monitoring (% of space free) for 5 directories. Here's what I'm working with: (snmpd.conf - disk and monitoring portions) # # Disk Usage monitoring: # disk / 20%... (0 Replies)
Discussion started by: Mariognarly
0 Replies

4. Shell Programming and Scripting

PERL: Replace multiple objects within a string

looking to replace parameters within a string with an external answer - with multiple replacements within a string %% will be used to wrap the objects to be replaced i.e. hello %%title%% %%user%% from %%address%% you last %%action%% on %%object%% the params will be used to make calls to a... (1 Reply)
Discussion started by: bidbrooken
1 Replies

5. UNIX for Dummies Questions & Answers

Awk - query about arrays

Hello again, I have example config file with two arrays: tab1="name1 surname1" tab1="name2 surname2" tab1="name3 surname3" tab2="First" tab2="Second"and csv file: "aaaaa","surname1","name1","ddddd,eeeee","ffffff","ggggg","3","2012/02/22 12:25:21","2012/02/22... (7 Replies)
Discussion started by: haczyk
7 Replies

6. Shell Programming and Scripting

perl - return an object from subroutine - Net::LDAP

Hi all, I'm not even sure a person can do this in perl, seems like you should be able to though. Here's the error IO::Socket::INET: connect: Operation now in progress at server_search.pl line 256, <DATA> line 466. Here's the perl code... sub ldap_new{ $nl = Net::LDAP->new( "$_" ) or... (3 Replies)
Discussion started by: jtollefson
3 Replies

7. Shell Programming and Scripting

Ldap search query

Hi All, I have a existing Ldap query which take a HOME as variable and gives the result where i grep for a particular line. ldapsearch -h server_domain_name -p 389 -D "uid=user,ou=appadm,o=ent" -w PaB -b "ou=roles,o=ent" "cidx=$HOME" | grep -w "ent: xyz" Now i have 330K Homes in a... (1 Reply)
Discussion started by: posner
1 Replies

8. Emergency UNIX and Linux Support

LDAP and AD Authentication Query

Hi Friends, I have below scenarios . dom1.test.com - LDAP dom2.test.com - AD Requirement is establish a trust relation between LDAP and AD server in such a way that if any user login on LDAP managed authentication server with dom1\username -> get authenticated by LDAP host ... (2 Replies)
Discussion started by: Shirishlnx
2 Replies

9. UNIX and Linux Applications

LDAP Group query

I need to write LDAP group query where I need to find if a particular user is a member of a 2 specific Groups. This is LDAP Novell edirectory implementation. Below are the details - ================ LDIF entry for OndotAPI group dn: cn=OndotAPI,ou=Groups,o=CNS changetype: add ... (0 Replies)
Discussion started by: jhamaks
0 Replies

10. UNIX for Advanced & Expert Users

LDAP Query - host allowed option

I have an in interesting dilemna that I am trying to address. I have some ldap queries that I use to retrieve user information to perform access validations on a quarterly/annual basis. I can successfully pull the local users, and I can use ldapsearch to pull back all the users from the DN as well.... (7 Replies)
Discussion started by: dagamier
7 Replies
Net::LDAP::Search(3)					User Contributed Perl Documentation				      Net::LDAP::Search(3)

NAME
Net::LDAP::Search - Object returned by Net::LDAP search method SYNOPSIS
use Net::LDAP; $mesg = $ldap->search( @search_args ); @entries = $mesg->entries; DESCRIPTION
A Net::LDAP::Search object is returned from the search method of a Net::LDAP object. It is a container object which holds the results of the search. METHODS
Net::LDAP::Search inherits from Net::LDAP::Message, and so supports all methods defined in Net::LDAP::Message. as_struct ( ) Returns a reference to a HASH, where the keys are the DNs of the results and the values are HASH references. These second level HASHes hold the attributes such that the keys are the attribute names, in lowercase, and the values are references to an ARRAY holding the values. This method will block until the whole search request has finished. count ( ) Returns the number of entries returned by the server. This method will block until the whole search request has finished. entry ( INDEX ) Return the N'th entry, which will be a Net::LDAP::Entry object. If INDEX is greater than the total number of entries returned then "undef" will be returned. This method will block until the search request has returned enough entries. entries ( ) Return an array of Net::LDAP::Entry objects that were returned from the server. This method will block until the whole search request has finished. pop_entry ( ) Pop an entry from the internal list of Net::LDAP::Entry objects for this search. If there are no more entries then "undef" is returned. This call will block if the list is empty, until the server returns another entry. references ( ) Return a list of references that the server returned. This will be a list of Net::LDAP::Reference objects. sorted ( ) Return a list Net::LDAP::Entry objects, sorted by their DNs. The sorting is done on the client side using Perl's alphanumerical sort operator "cmp". sorted ( ATTR, ... ) Return a list of Net::LDAP::Entry objects, sorted by the specified attributes. The attributes are compared in the order specified, each only being compared if all the prior attributes compare equal. The sorting is done on the client side using Perl's alphanumerical sort operator "cmp". shift_entry ( ) Shift an entry from the internal list of Net::LDAP::Entry objects for this search. If there are no more entries then "undef" is returned. This call will block if the list is empty, until the server returns another entry. SEE ALSO
Net::LDAP, Net::LDAP::Message, Net::LDAP::Entry, Net::LDAP::Reference ACKNOWLEDGEMENTS
This document is based on a document originally written by Russell Fulton <r.fulton@auckland.ac.nz>. AUTHOR
Graham Barr <gbarr@pobox.com> Please report any bugs, or post any suggestions, to the perl-ldap mailing list <perl-ldap@perl.org>. COPYRIGHT
Copyright (c) 1997-2004 Graham Barr. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.12.1 2008-06-30 Net::LDAP::Search(3)
All times are GMT -4. The time now is 02:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy