Solved

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

Posted on 2014-10-20
1
216 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Find out how to use Active Directory data for email signature management in Microsoft Exchange and Office 365.
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 tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

757 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now