CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Net:LDAP::Search

 



winfinit
User

Sep 15, 2007, 1:54 PM

Post #1 of 3 (361 views)
Net:LDAP::Search Can't Post

Hi
i am trying to send output of my search into array for further sorting, and i am dont know how, i tried to experiment, but all i am getting is HASH value in my array... please tell me what i am doing wrong

8888888888888888888
#!/usr/bin/perl

use Net::LDAP;
$ldap = Net::LDAP->new('###.#####.####');
$ldap->bind('#######', password=>'######', version=>3);

$mesg = $ldap->search(filter=>"(cn=########1*)", base=>'DC=######,DC=########,DC=net',attrs => ['1.1']);

#all this below is to dump all the info to the screen
@entries = $mesg->entries;
foreach $entry (@entries) {
$entry->dump;
}

$ldap->unbind;

8888888888888888888888888888888

dump is just sending output to the screen, but i need it to be pushed into my array for example @array...

Thank You in advance...


KevinR
Veteran


Sep 15, 2007, 2:04 PM

Post #2 of 3 (359 views)
Re: [winfinit] Net:LDAP::Search [In reply to] Can't Post

maybe:


Code
foreach $entry (@entries) { 
push @array, $entry->dump;
}

-------------------------------------------------


(This post was edited by KevinR on Sep 15, 2007, 3:37 PM)


winfinit
User

Sep 15, 2007, 2:23 PM

Post #3 of 3 (357 views)
Re: [winfinit] Net:LDAP::Search [In reply to] Can't Post

that one actually didnt work, for some reason it is giving me a hash value of my search
Ex.
Net::LDAP::Entry=HASH(0x18decf4)

but i found a solution

here is a working code

888888888888888
#!/usr/bin/perl

use Net::LDAP;

$ldap = Net::LDAP->new('#########');
$ldap->bind('#######', password=>'######', version=>3);

#attrs => ['1.1'] is so that we dont dump unnecessary info to array, we only need DN, since thats
#where we can extract our master UID as OU attribute
$mesg = $ldap->search(filter=>"(cn=#######*)",
base=>'DC=exch016,DC=#######,DC=net',
attrs => ['1.1']
);

#store value for further breakdown;
chomp($value=$mesg->entry->dn); #<- this is what i was looking for
#also you can extract any number of entry like #chomp($value=$mesg->entry(5)->dn);

$ldap->unbind;

print $value; #or do what ever with it
88888888888888888

Thank you Kevin for your reply

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives