Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2014-10-20
1
Medium Priority
?
345 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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

876 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