Re: question

Graham Barr <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.ldap
Message-ID <[email protected]>
On Jan 15, 2009, at 7:58 AM, Daniel Chojecki wrote:
> is it possible to fetch all baseDNs from ldap server ?
>
> Could you show some examples, because i'm quit new to perl language.

Any DN can be used as a baseDN for a search, so I assume you mean the  
base of all the trees known to the server. This can be obtained from  
the namingContexts attribute in the RootDSE entry

Here is a piece of code, minus some error checking, that was posted  
recently that will do a search on all namingContexts

my $ldap = Net::LDAP->new( 'localhost' );
my $dse = $ldap->root_dse;
foreach my $base ($dse->get_value('namingContexts')) {
   my $search = $ldap->search(
     base   => $base,
     filter => '(objectclass=dcObject)',
   );
   foreach my $entry ($search->entries) {
     $entry->dump;
   }
}

Graham.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.