Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

863 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

28 Experts available now in Live!

Get 1:1 Help Now