Solved

Can I create a lookup in Access to Active Directory like in SharePoint does for contact information?

Posted on 2013-01-07
3
303 Views
Last Modified: 2013-01-08
I have a form in Access that creates user information in my database.  Can I create a table or form in Access that will look in Active Directory to populate:

LoginID
First
Last
Phone
Email

The function will act the same as when you click on the address book picture in SharePoint it automatically searches the active directory to pull in Login Information?
0
Comment
Question by:gracie1972
  • 2
3 Comments
 
LVL 39

Expert Comment

by:als315
Comment Utility
You can find sample here:
http://www.access-programmers.co.uk/forums/showthread.php?t=209929
For filtering you can use current user's login name:
Environ("username"). You can also take domain from environ:
Environ("userdomain")
0
 

Author Comment

by:gracie1972
Comment Utility
I don't actually need to create new exchange accounts, the link you sent me does this.
What I need is to populate a table pulling information from Active Directory.
0
 
LVL 39

Accepted Solution

by:
als315 earned 500 total points
Comment Utility
Try this sub (extracted from link above):
Option Compare Database
Option Explicit
Public Const adOpenStatic     As Integer = 3
Public Const adLockReadOnly   As Integer = 1
Public Const adCmdUnspecified As Integer = -1


Sub GetADUserInfo()
Dim rs As Object
Dim StrSQL As String

    Set rs = CreateObject("ADODB.Recordset")
    StrSQL = "SELECT userPrincipalName, name, sAMAccountName, department, streetAddress, mail, telephoneNumber, otherTelephone " & _
             "FROM 'LDAP://DC=yourDomain,DC=local'" & _            ' Correct this line according to your domain
             "WHERE objectClass='user' AND objectCategory='Person' AND sAMAccountName = '" & Environ$("username") & "'"
    
    rs.Open StrSQL, "Provider=ADSDSOObject;", adOpenStatic, adLockReadOnly, adCmdUnspecified
    If rs.RecordCount > 0 Then
        Debug.Print rs!sAMAccountName, rs!mail, rs!Name
    End If
    rs.Close
    Set rs = Nothing
End Sub

Open in new window

0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…

728 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

9 Experts available now in Live!

Get 1:1 Help Now