WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

ADSI LDAP CDO
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

List of AD Domains

 Keywords:  List of Active Directory ADSI AD Domains

Question:

I need to get a list of AD domains from the rootDSE to allow admins to select the domain they wish to view objects in. How can I accomplish this.

Answer:


strFilter = "(NETBIOSName=*)"
objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open("Active Directory Provider")
objRootDSE = GetObject("LDAP://RootDSE")
cNC = objRootDSE.Get("configurationNamingContext")
STRING = "<LDAP://" : cNC : ">;" : strFilter : ";" : "dnsroot,ncname;subtree"
objRecordSet = objConnection.Execute(STRING)
While !objRecordSet.EOF
   ncname = objRecordSet.Fields("ncname").Value
   dnsroot = objRecordSet.Fields("dnsroot").Value
   dnsroot = dnsroot[ArrInfo(dnsroot, 1 )-1]
   Pause('dns root',dnsroot)
   objRecordSet.MoveNext
EndWhile
Exit

Article ID:   W18053
Filename:   List of AD Domains.txt
File Created: 2011:09:20:11:10:28
Last Updated: 2011:09:20:11:10:28