Access 2010 - Active Directory Lookup (1 Viewer)

Armaganon00

New member
Local time
Today, 03:28
Joined
Jul 20, 2015
Messages
5
Hello,
I have a database that, I would like to add a button that performs a active directory lookup. I would like it to check a username with Active Directory, and auto populate a few fields.

First Name
Last Name
Manager
Department

This is my first database and I have very little exp using VBA. So if any one could help me out, or point me in the right direction.
 

Armaganon00

New member
Local time
Today, 03:28
Joined
Jul 20, 2015
Messages
5
The sad part is that I barely know what I am looking at. That site looks check ad against a group. But I have no idea how to take pieces of code that I need.
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 18:28
Joined
Jan 20, 2009
Messages
12,852
Search this forum for LDAP and my username. I have posted here many times on the subject.
 

Armaganon00

New member
Local time
Today, 03:28
Joined
Jul 20, 2015
Messages
5
Search this forum for LDAP and my username. .

I have spent many hours reading through these forms. I have no Idea what to edit or what code aplies to my situation. I am a VBA noob.

I have a form that I would like to putton a button that checks the username field and populates several other fields. If the username does not check out then it puts up a message box.

Here is some code i found: So how do I call it? What do I edit?
Private Sub Command25_Click()
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") = "displayname"

objCommand.CommandText = _
"SELECT GivenName, displayname FROM 'LDAP://OU=Users,OU=NB,OU=NA,OU=Fluor,DC=fdnet,DC=com' WHERE objectCategory='user'"

Set objRecordSet = objCommand.Execute

objRecordSet.MoveFirst

With objRecordSet

Do Until .EOF

Debug.Print .Fields("Name") & " : " & .Fields("displayname")
.MoveNext

Loop

End With

End Sub
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 18:28
Joined
Jan 20, 2009
Messages
12,852
I have spent many hours reading through these forms. I have no Idea what to edit or what code aplies to my situation. I am a VBA noob.

I have a form that I would like to putton a button that checks the username field and populates several other fields. If the username does not check out then it puts up a message box.

You are "trying to run before you can walk". Try doing some simple code to write to and from the controls on a form. Then ask simple questions if you run into trouble with that.

Asking about Active Directory makes of the helpful people not look because it is complex and not many know much about it. Those who do know about it aren't inclined to spend time showing you the basics of coding VBA.
 

Armaganon00

New member
Local time
Today, 03:28
Joined
Jul 20, 2015
Messages
5
Thats why I was hoping someone would take a look at my data base and help build something. I would be willing to send a gift card for the assistance.
 

Users who are viewing this thread

Top Bottom