|
GroupMembership.vbs
which groups the user belongs to. The function do NOT assume that user and computer is in the same domain.
Dim Container
Dim ContainerName
Dim Group
UserName = Inputbox ("User Account to search for ", "UserName","USERNAME")
ContainerName = Inputbox ("Resource Domain to search in: ", "Resource Domain","Computer_Domain")
UserDomain = Inputbox ("Account Domain in which user exists: ", "Account Domain","User_Domain")
Set Container = GetObject("WinNT://" & ContainerName)
Set User = GetObject("WinNT://" & UserDomain & "/" & UserName & ",user")
Container.Filter = Array("Group")
sGroup = "UserName: " & VbTab & UserName & VbCrLf &_
"ResourceDomain: " & VbTab & ContainerName & VbCrLf &_
"AccountDomain: " & VbTab & UserDomain & VbCrLf & VbCrLf &_
"___________________________" & VbcrLf & VbCrLf &_
"Group Membership:" & VbCrLf
For Each Group in Container
If Group.IsMember(User.ADsPath) = true Then
sGroup = sGroup & VbCrLf & Group.Name
End If
Next
Msgbox sGroup, ,"Group Membership"
|