Is it possible to connect Active Directory in Microsoft Access?

Posted on 2007-07-30
Last Modified: 2010-05-18
Dear all experts,

Just wonder is it possible to connect the Active Directory by using ADSI under Microsoft Access.  As I know that in SQL Server, I can use the following query to connect to my AD

FROM "ldap://dc=bs,dc=brookes,dc=ac,dc=uk" WHERE
objectCategory = "Person" AND objectClass= "user"')

Now, I would like to know is it possible to implement it in Microsoft Access environment.

Question by:towo2002
    LVL 11

    Accepted Solution

    Will something like this do you?

      Set objConnection = CreateObject("ADODB.Connection")
      Set objCommand = CreateObject("ADODB.Command")
      objConnection.Provider = "ADsDSOObject"
      objConnection.Open "Active Directory Provider"
      Set objCommand.ActiveConnection = objConnection

      objCommand.Properties("Page Size") = 1000
      objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

      objCommand.CommandText = _
          "SELECT Department, Title, sAMAccountName FROM 'LDAP://dc=corphq,dc=co,dc=uk' WHERE objectCategory='user' "
            '"AND Department !=''"
      Set objRecordset = objCommand.Execute

    That was taken from .  I have used code similar to this (I don't have it anymore unfortunately!) in the past to get a list of usernames frmo AD for an Access database logon page...
    LVL 1

    Author Comment

    Dear Zenith63,

    Thanks for your quick reply.  However, is it possible to implement it in "table" or "query"  way?  By using the script that you provided seems can only works on VBA form.  Since I would like to bind the AD objects to the access datagrid / combo box directly, it will be great if it can binds it in "query" or "table" format

    LVL 11

    Expert Comment

    Sorry I can't offer any more help with this, I just saw the question and remembered doing something similar so thought I'd post it.  There is quite a bit of info about this on Google though if you search for something like "Query Active Directory from Access VBA"

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    This article is a continuation or rather an extension from Cascading Combos ( and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
    Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
    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 from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
    With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

    779 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

    14 Experts available now in Live!

    Get 1:1 Help Now