Professional Documents
Culture Documents
"ADSI Sample - Domain List" "Domains Found: ": Option Explicit Dim Dim
"ADSI Sample - Domain List" "Domains Found: ": Option Explicit Dim Dim
vbs
'************************************************
' File: ListDomains.vbs (WSH sample in VBScript)
' Author: G. Born
'
' Lists the domains in a network
'************************************************
Option Explicit
Dim oNameSpace, oItem
Dim txt, title
title = "ADSI sample - Domain list"
txt = "Domains found: " & vbCRLF
' bind to ADs, if we just connect to the provider,
' we get a connect to namespace object
Set oNameSpace = GetObject("WinNT:")
' Now apply a filter to the domain
' to retrieve the requested data.
oNameSpace.Filter = Array("domain")
' Enumerate domains
For Each oItem in oNameSpace
txt = txt & oItem.Name & vbCRLF
Next
MsgBox txt, vbOkonly, title
' End
-1-