Use list of active directory users in ms access 2007 dropdown
3 answers
Try something like this:
'Use ADO and LDAP to return all users in Active Directory
Dim objRecordSet As Object
Dim objCommand As Object
Dim objConnection As Object
Const ADS_SCOPE_SUBTREE = 2
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.Properties("Sort On") = "Name"
objCommand.CommandText = _
"SELECT Name FROM 'LDAP://dc=<enter domain controler server name here>,dc=<enter full AD domain name here>' WHERE objectCategory='user'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
Debug.Print objRecordSet.Fields("Name").Value
objRecordSet.MoveNext
Loop
This should get a list of users. Note that you will need to provide the domain controller server name and AD domain name.
Hope this helps Mark
+2
a source to share
I just integrated AD with Access. Here's a great explanation and sample code: http://www.accesssecurityblog.com/post/2011/02/05/Securing-Access-databases-using-Active-Directory.aspx
+1
a source to share
I've never done this, but I read that it enables LDAP queries through ADO, but I don't know what provider name or connection strings are needed. You can find this site for articles on LDAP queries for AD for some examples. They won't respond to access, but they can show you what to do in Access.
0
a source to share