when I try to find a user if is a member of a group it takes too long. Will it be possible to filter base DN for the LDAP search?
Here is the function.
' *****************************************************
'This function checks if the given AD user is a member of the given group.
Function IsMember(domainName,userName,groupName)
Set groupListD = CreateObject("Scripting.Dictionary")
groupListD.CompareMode = 1
ADSPath = domainName & "/" & userName
Set objUser = GetObject("WinNT://" & ADSPath & ",user")
For Each objGroup in objUser.Groups
groupListD.Add objGroup.Name, "-"
Next
IsMember = CBool(groupListD.Exists(groupName))
End Function
' *****************************************************
Thank you
You don't need to go through all groups once you have found the matching group, this should help:
Also, there's no need to create and add group names to a Dictionary.