# extended LDIF # # LDAPv3 # base 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: $VAR1 = bless( { 'attrs' => { 'friendlyid' => [ 'Pizza' ], 'idcreatedon' => [ '27-02-2099 00:00:00' ] }, 'changes' => [], 'asn' => { 'objectName' => 'uid=userid,ou=help,dc=perl,dc=monks', #### #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"; #### #!/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"; }