Showing posts with label VBA. Show all posts
Showing posts with label VBA. Show all posts

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

Wednesday, September 2, 2009

Is User member of AD group - VBA

Came across this small function which returns true or false based on the user belonging to a AD group. No need to add a reference to any dll. Very short and works great.

Quote:
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
Thanks to Greg Reddick
Link: http://my.advisor.com/doc/08691