Platform SDK: Active Directory, ADSI, and Directory Services

Listing Groups

To list the groups in a particular domain, simply apply a "group" filter to the domain object and enumerate it. The following code lists the groups in the "mydomain" domain:

Dim myDomain
Dim group

Set myDomain = GetObject("WinNT://mydomain")

myDomain.Filter = Array("group")
For Each group In myDomain
    WScript.Echo group.Name
Next