Dim UserObj
Dim GroupObj
UserString = InputBox("The User name that you would like to check")
arrDomains = Array("CSC", "CS")
For Each DomainString In arrDomains
'DomainString="CSC"
List = List & "**********************************************"& VbCrLf
List = List & DomainString & " Group Membership" & VbCrLf
List = List & "**********************************************"& VbCrLf
List = List & VbCrLf
On Error Resume Next
Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)
If Err.Number = 0 Then
On Error GoTo 0
For Each GroupObj In UserObj.Groups
List = List & GroupObj.Name & VbCrLf
Next
Else
Err.Clear
On Error GoTo 0
List = List & "User does not exist of " & DomainString
End If
Next
WScript.Echo List
|