Friday, September 25, 2009

AD Group membership lookup - VBA

Found this function to check AD membership of a user from VBA. Very simple and short function.

I'm not sure where I got this from but if the author sees it, please let me know and I'll link to your website.

Function IsMember(strDomain As String, strGroup _
As String, strMember As String) As Boolean
Dim grp As Object
Dim strPath As String

strPath = "WinNT://" & strDomain & "/"
Set grp = GetObject(strPath & strGroup & ",group")
IsMember = grp.IsMember(strPath & strMember)
End Function

No comments: