Sorry, I posted as I was walking out the door Friday. It should've been:
Set oHeaven = GetObject("WinNT://MyDomain/MyGroup,Group"
MsgBox oHeaven.IsMember("WinNT://MyDomain/MyUser"
But one thing you may want to consider, is that the IsMember function does not recursively check membership. Thus if your GroupA contains only one member, GroupB, and your UserA is a member of GroupB, you may/may not get the results you desire.
Depending on how you want this reported, you may want to implement a recursive function:
Function IsMember(domain, group, user)
Dim oGroup
Dim oMemb
Dim aTemp
IsMember = False
Set oGroup = GetObject("WinNT://" & domain & "/" & group & ",group"
If oGroup.IsMember("WinNT://" & domain & "/" & user) Then
IsMember = True
Exit Function
End If
For Each oMemb In oGroup.Members
If oMemb.Class = "Group" Then
aTemp = Split(oMemb.ADsPath, "/"
IsMember = IsMember(aTemp(2), aTemp(3), user)
If IsMember Then Exit For
End If
Next
End Function Jon Hawkins
Hmm, thanks jonscott8. I will definitely look into that. Although the lack of recursion isn't causing a problem now and will probably never cause a problem I will certainly take a look at that code and make the change if works well.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.