troubleshooting Question

VBScript What groups user is member of

Avatar of dcarrion
dcarrion asked on
Windows 2000
2 Comments1 Solution319 ViewsLast Modified:
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.Network")
      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
Chris Dent
PowerShell Developer
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros