Solved

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

Posted on 2014-10-20
1
277 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

617 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