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.