Solved

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

Posted on 2013-01-07
3
308 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 40

Expert Comment

by:als315
ID: 38751706
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
ID: 38751765
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 40

Accepted Solution

by:
als315 earned 500 total points
ID: 38751984
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Form performance table vs. query 27 66
Sub form showing data is being saved but cannot be displayed.. 31 64
Microsoft Access 32-bit or 64-bit? 11 56
SUBFORM on ACCESS 2013 8 28
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

737 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