Solved

How can MS Access retrieve a list of users in an Active Directory Group

Posted on 2014-10-20
1
225 Views
Last Modified: 2014-10-24
i use the following function to test if a user is in an active directory group.  it there a way i can query all the user in a know AD group.

If IsMember("WI", rst!txtGroupName, Environ("UserName")) = True Then


Public Function IsMember(strDomain As String, strGroup _
   As String, strMember As String) As Boolean
   On Error GoTo Err_ctlExport_Click

    Dim grp As Object
    Dim strPath As String
 
    strPath = "WinNT://" & strDomain & "/"
    Set grp = GetObject(strPath & strGroup & ",group")
    IsMember = grp.IsMember(strPath & strMember)

Exit_ctlExport_Click:
    Exit Function
   
Err_ctlExport_Click:
    IsMember = False
    Exit Function
End Function
0
Comment
Question by:RDLFC
1 Comment
 
LVL 7

Accepted Solution

by:
slubek earned 500 total points
ID: 40393709
Sub GetADGroupMembers(strGroup as String)
    Set objConnection = CreateObject("ADODB.Connection")
    Set objCommand = CreateObject("ADODB.Command")
    
    objConnection.Provider = "ADsDSOObject"
    objConnection.Open "Active Directory Provider"
    
    Set objCommand.ActiveConnection = objConnection
    objCommand.CommandText = _
        "SELECT ADsPath, Name FROM 'LDAP://OU=OrganizationUnit,OU=Department,DC=Domain' WHERE objectCategory='group' and Name='" & strGroup & "'"

    Set objRecordSet = objCommand.Execute
    Set objGroup = GetObject(objRecordSet.Fields("ADsPath").Value)
    strGroupName = objRecordSet.Fields("Name").Value
    arrMemberOf = objGroup.GetEx("Member")
        For Each strMemberOf In arrMemberOf
            Set objMember = GetObject("LDAP://" & strMemberOf)
            strMemberName = Right(objMember.Name, Len(objMember.Name) - 3)
            ' Do something with strMemberName
                
            Set objMember = Nothing
        Next
    Set objGroup = Nothing
End Sub

Open in new window

0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question