Hi Graham, Really Thanks a lot for this code. its works perfectly fine.
Thanks, Omi. On Tue, Jan 6, 2009 at 6:14 PM, Graham Barr <gb...@pobox.com> wrote: > On Jan 6, 2009, at 4:12 AM, omkar kulkarni wrote: > >> ok Let me tell you my actual Use Case: >> >> I am developing one tool called ldaphelper. >> what this tool will do is : >> ldaphelper -discover : this will connect to local machine and try to find >> out all available domains (DC Objects) in that ldap DIR and write to XML >> with som attributes those I needed for another project, that project pick >> up >> that XML and add that domain as LDAP domain in >> my project for Authenticvation purpose. >> > > OK, from this description I assume you also do not know a base DN to start > the search from. to get that you will need to get the namingContexts from > the root DSE. Try something like (untested and you will need to add error > handling) > > 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. > >