Is it possible to connect Active Directory in Microsoft Access?

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

SELECT * FROM OpenQuery( ADSI, 'SELECT name
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.

Regards,
LVL 1
towo2002Asked:
Who is Participating?
 
Zenith63Commented:
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 http://www.tek-tips.com/viewthread.cfm?qid=1384174&page=7 .  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...
0
 
towo2002Author Commented:
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

Thanks,
0
 
Zenith63Commented:
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"
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.