Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

question

6 views
Skip to first unread message

Daniel Chojecki

unread,
Jan 15, 2009, 8:58:29 AM1/15/09
to perl...@perl.org
Hello,

is it possible to fetch all baseDNs from ldap server ?

Could you show some examples, because i'm quit new to perl language.

Best Regards,
Daniel

Graham Barr

unread,
Jan 15, 2009, 9:59:21 AM1/15/09
to Daniel Chojecki, perl...@perl.org
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.

Daniel Chojecki

unread,
Jan 16, 2009, 2:05:16 AM1/16/09
to Graham Barr, perl...@perl.org
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> 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.

i thought about it.

> 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;
> }
> }

thx, it is working !

Best Regards,
Daniel
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAklwMaIACgkQ2o8fdEaIvhbnUwCfa8DCOQvFk59SxEVZYqyUHV4p
lsoAoLV4+Cjpr4/LfmLx/rvTPhYy4EPt
=bohE
-----END PGP SIGNATURE-----

0 new messages