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::Control::SyncDone(3) 			User Contributed Perl Documentation			   Net::LDAP::Control::SyncDone(3)

NAME
Net::LDAP::Control::SyncDone - LDAPv3 Sync Done control object SYNOPSIS
See Net::LDAP::Control::SyncRequest DESCRIPTION
"Net::LDAP::Control::SyncDone" provides an interface for the creation and manipulation of objects that represent the "Sync Request Control" as described by RFC 4533. CONSTRUCTOR ARGUMENTS
In addition to the constructor arguments described in Net::LDAP::Control the following are provided. cookie refreshDeletes METHODS
As with Net::LDAP::Control each constructor argument described above is also available as a method on the object which will return the current value for the attribute if called without an argument, and set a new value for the attribute if called with an argument. SEE ALSO
Net::LDAP, Net::LDAP::Control, Net::LDAP::Control::SyncRequest, Net::LDAP::Control::SyncState, http://www.ietf.org/rfc/rfc4533.txt AUTHOR
Mathieu Parent <math.parent@gmail.com> Please report any bugs, or post any suggestions, to the perl-ldap mailing list <perl-ldap@perl.org> COPYRIGHT
Copyright (c) 2008 Mathieu Parent. 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.16.2 2012-09-20 Net::LDAP::Control::SyncDone(3)
All times are GMT -4. The time now is 09:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy