Solved

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

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

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…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

626 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