3dbc has asked for the wisdom of the Perl Monks concerning the following question:
What I'm interested in is the objectname above which happens to be the dn and holds the information i need to formulate my report, along with the other data in the object. my problem is that i can't access the dn object within each entry, but can access the other attributes available in the ldif. I see them in data dumper out put and can access them via standard methods. i.e. entry->get_value("attribute-name"), but this doesn't work for the dn...# extended LDIF # # LDAPv3 # base <ou=help,dc=perl,dc=monks> with scope subtree # filter: (|(Id1=*)(Id2=*)) # requesting: dn FriendlyId CreatedOn # # userid, help, perlmonks.com dn: uid=userid,ou=help,dc=perl,dc=monks FriendlyId: Pizza IdCreatedOn: 27-02-2099 00:00:00 data dumper displays the dn's in its output via data dumper: <code> $VAR1 = bless( { 'attrs' => { 'friendlyid' => [ 'Pizza' ], 'idcreatedon' => [ '27-02-2099 00:00 +:00' ] }, 'changes' => [], 'asn' => { 'objectName' => 'uid=userid,ou=help,dc=per +l,dc=monks',
above won't pull back the object name which has the dn i need to access and itterate through along with the other elements of the hash.#i.e. these work: print $entry->get_value("IdCreatedOn")."\n"; print $entry->get_value("FriendlyId")."\n"; #but can't get the dn: print $entry->get_value("dn")."\n"; print $entry->get_value("objectName")."\n";
looking for some jedi ldif reporting experts, I know you're out there!! ...and probably can solve this very quickly, THANK YOU!.#!/usr/bin/perl use Net::LDAP::LDIF; use Net::LDAP::Entry; use Data::Dumper; use strict; use warnings; my $ldif = Net::LDAP::LDIF->new( "../packages/ldapsearch2.ldif", "r") +or die "file not exits\n"; while( not $ldif->eof ( ) ) { my $entry = $ldif->read_entry ( ); #this doesn't work print "HERE is the DN!!!"."\n"; # 'asn' => { # 'objectName' print "anything?" . "\n". $ldif->{'asn'}{'objectName'}. "\n"; # but this shows the dn's in the output, but how do I get them +to print? print Dumper $entry; } #the following doesn't work.. my @arrayOfDNs = keys %$ldif; print "here are all the dn's:"."\n"; print @arrayOfDNs;
foreach my $key (keys %{$ldif}) { print "\n this is the key:" . $key . "\n"; #need to dereference the subkeys... not working yet below. #for my $subkey ( keys %{$ldif{$key}} ) { # print "Subkey=$$ldif{$key}{$subkey} "; #} print "\n" . "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: can't access dn within ldif file
by NetWallah (Canon) on Dec 27, 2017 at 03:04 UTC | |
by 3dbc (Monk) on Dec 27, 2017 at 15:15 UTC | |
by NetWallah (Canon) on Dec 27, 2017 at 18:10 UTC | |
|
Re: can't access dn within ldif file
by poj (Abbot) on Dec 26, 2017 at 22:03 UTC |