I'm using IsMember to check for Domain Admins. I must be doing something
wrong because it comes back positive for all users. Here's the code
strGroup = "Domain Admins"
If IsMember(strGroup) Then
MsgBox "Hello"
End If
Function IsMember(strGroup)
' Function to test for group membership.
' strGroup is the NT name (sAMAccountName) of the group to test.
' objGroupList is a dictionary object, with global scope.
' Returns True if the user is a member of the group.
If IsEmpty(objGroupList) Then
Call LoadGroups
End If
IsMember = objGroupList.Exists(strGroup)
End Function
Sub LoadGroups
' Subroutine to populate dictionary object with group memberships.
' objADObject is the user object, with global scope.
' objGroupList is a dictionary object, with global scope.
Dim objGroup
Set objGroupList = CreateObject("Scripting.Dictionary")
objGroupList.CompareMode = vbTextCompare
For Each objGroup In objADObject.Groups
objGroupList(objGroup.name) = True
Next
Set objGroup = Nothing
End Sub