Solved

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

Posted on 2013-01-07
3
306 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
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 39

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

777 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