dcarrion
asked on
VBScript What groups user is member of
Hello
Just working on a script to return boolean if user is a member of group. However I want to go one step further and also list subgroups of groups etc...This is what I have at the moment
Private Function IsMember(groupName)
Set netObj = CreateObject("WScript.Netw ork")
domain = "domain.local"
user = netObj.UserName
flgIsMember = false
Set userObj = GetObject("WinNT://" & domain & "/" & user & ",user")
For Each grp In userObj.Groups
if LCase(grp.Name) = LCase(groupname) then
flgIsMember=True
Exit For
end if
Next
IsMember = flgIsMember
Set userObj = nothing
Set netObj = nothing
End Function
I want it so I can go one step further in the For Loop so I can search subgroups as well...Any assistance would be much appreciated.
Thanks
Just working on a script to return boolean if user is a member of group. However I want to go one step further and also list subgroups of groups etc...This is what I have at the moment
Private Function IsMember(groupName)
Set netObj = CreateObject("WScript.Netw
domain = "domain.local"
user = netObj.UserName
flgIsMember = false
Set userObj = GetObject("WinNT://" & domain & "/" & user & ",user")
For Each grp In userObj.Groups
if LCase(grp.Name) = LCase(groupname) then
flgIsMember=True
Exit For
end if
Next
IsMember = flgIsMember
Set userObj = nothing
Set netObj = nothing
End Function
I want it so I can go one step further in the For Loop so I can search subgroups as well...Any assistance would be much appreciated.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You may want to remove this line:
WScript.Echo Space(x) & objGroup.Get("name")
It just echo's out the group names in a tree type format if you're running it with CScript on the command line.
Chris