Directory Services |
To list the groups in a particular domain, apply a "group" filter to the domain object and enumerate it. The following code example lists the groups in the "mydomain" domain.
Dim myDomain As IADs Dim group As IADs On Error GoTo Cleanup Set myDomain = GetObject("WinNT://mydomain") myDomain.Filter = Array("group") For Each group In myDomain WScript.Echo group.Name Next Cleanup: If (Err.Number<>0) Then MsgBox("An error has occurred. " & Err.Number) End If Set myDomain = Nothing Set group = Nothing