Re: Need help to search all dc's available

Buchan Milne <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.ldap
Message-ID <[email protected]>
On Tuesday 06 January 2009 10:57:17 omi wrote:
> On Jan 6, 1:15 pm, [email protected] (Buchan Milne) wrote:
> > On Monday 05 January 2009 19:56:03 omkar wrote:
> > > hi all,
> > > I am trying to write one tool, that could find the all available dc
> > > values.
> >
> > You should pose your problem more precisely. E.g., maybe you would prefer
> > to find the DC values for all entries of objectclass domain?
> >
> > > see example:
> > > -> base dn: dc=A, dc=B, dc=C
> > >                   ou =users, dc=A, dc=B, dc=C
> > >                   ou= groups,dc=A, dc=B, dc=C
> > >                   dc=D, dc=A, dc=B, dc=C
> > >                             ou=users, dc=D, dc=A, dc=B, dc=C
> > > something like structure I have in LDAP DIR,
> > > now I just want to find out all avalable dc's by accepting base dn as
> > > input in PERL:LDAP.
> >
> > Relying on the DN to be composed of the value you want is not necessarily
> > the best LDAP practice.
> >
> > Why don't you search your base DN with a filter of (objectclass=domain)
> > and request the DC attribute. It will accomplish the same thing, but in a
> > much more robust way.
> >
> > Regards,
> > Buchan
>
> OK did you mean like this:
>
> I did following but it wont work.
>
> my($ldap) = Net::LDAP->new('127.0.0.1')
> my($mesg) = $ldap->search(filter => '(objectclass=domain)');
> foreach $entry ($mesg->all_entries)
> {
> my $en_dn = $entry->dn();
> }
> But nothing is get printed. : (
> will Please go through this code and tell me what I am missing from
> code point of view.

1)No error handling
2)No bind (which (1)  after $ldap->search would have shown you)

If this *is* AD (you haven't said yet), then note that by default  AD requires 
you to bind as non-anonymous to see anything but the empty DN.

Regards,
Buchan
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.