Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2013-01-07
3
Medium Priority
?
311 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 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

972 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