Solved

Get the contact information using userid

Posted on 2009-03-30
12
210 Views
Last Modified: 2012-05-06
Hi,

I have an user id. Could any one please help me to get contact info(like Home phone number, Mobile number, address) using this user id. When I double click on user id, I get an attached info dialog. Basically we need to fetch this infor.

Thanks.
0
Comment
Question by:deshaw
  • 6
  • 5
12 Comments
 
LVL 1

Author Comment

by:deshaw
ID: 24026363
forgotton attachment. Please find it here.
userid-prop.JPG
0
 
LVL 2

Expert Comment

by:Shallwin
ID: 24026392
All that information is from Active Directory.  Write a VB script to extract and display the information you need.  See MSDN for a list of all the attributes:
http://msdn.microsoft.com/en-us/library/ms675085(VS.85).aspx
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24026915
Hi, deshaw.

Here's a sample bit of VBScript showing how to do this.  
Set rsDetails = Wscript.CreateObject("ADODB.Recordset")

rsDetails.ActiveConnection = "Provider=ADSDSOObject"

'Replace DomainName on the following line with the name of your domain and jdoe with the account name you want to search for'

rsDetails.Source = "SELECT ADsPath, displayName, Company, Department, Division FROM 'LDAP://DomainName' WHERE objectClass='user' AND objectCategory='Person' AND samAccountName='jdoe'"

rsDetails.CursorType = 0

rsDetails.CursorLocation = 2

rsDetails.LockType = 1

rsDetails.Open()

If Not rsDetails.EOF Then

    With rsDetails

        Wscript.Echo "Name=" & .Fields("displayName") & " Company=" & .Fields("Company") & " Department=" & .Fields("Department") & " Division=" & .Fields("Division")

    End With

End If

rsDetails.Close

Set rsDetails = Nothing

Open in new window

0
 
LVL 1

Author Comment

by:deshaw
ID: 24027209
Thanks Shallwin and BlueDavilFan for your replies but I didnot get any VBA  example on that page. Could you please point me if any example?
BlueDavilFan, Can we convert this VBScript to VBA macro?
Thanks.
0
 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 24027222
Yes.  Simply put it in a subroutine and change WScript.Echo to MsgBox.  Something like this.  Keep in mind that this is just a demonstration of how to do this.  It does not return all the information you want.  
Sub GetContactInfo()

    Set rsDetails = Wscript.CreateObject("ADODB.Recordset")

    rsDetails.ActiveConnection = "Provider=ADSDSOObject"

    'Replace DomainName on the following line with the name of your domain and jdoe with the account name you want to search for'

    rsDetails.Source = "SELECT ADsPath, displayName, Company, Department, Division FROM 'LDAP://DomainName' WHERE objectClass='user' AND objectCategory='Person' AND samAccountName='jdoe'"

    rsDetails.CursorType = 0

    rsDetails.CursorLocation = 2

    rsDetails.LockType = 1

    rsDetails.Open()

    If Not rsDetails.EOF Then

        With rsDetails

            MsgBox "Name=" & .Fields("displayName") & " Company=" & .Fields("Company") & " Department=" & .Fields("Department") & " Division=" & .Fields("Division")

        End With

    End If

    rsDetails.Close

    Set rsDetails = Nothing

End Sub

Open in new window

0
 
LVL 1

Author Comment

by:deshaw
ID: 24038112
BluDevilFan, what is the type of " rsDetails" variable. Macro giving a syntax error at rsDetails.Open()

Thanks.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 76

Expert Comment

by:David Lee
ID: 24038201
Sorry, I missed one instance of WScript in the code.  Change line 2 to

     Set rsDetails = CreateObject("ADODB.Recordset")
0
 
LVL 1

Author Comment

by:deshaw
ID: 24038221
Thats cool and also we will need to change   rsDetails.Open() to   rsDetails.Open. :)

BlueDevilFan, Could you please help me on http://www.experts-exchange.com/Software/Office_Productivity/Groupware/Outlook/Q_24280082.html
I think you know the complete problem I faced while writing my first Add-in :) Now problem is narrow down to creating registry entries. Alternatively, it is also fine if I could register Add-in dll as normal user.
Thanks.
 
0
 
LVL 1

Author Comment

by:deshaw
ID: 24038237
Also do we need below lines?
    rsDetails.CursorType = 0
    rsDetails.CursorLocation = 2
    rsDetails.LockType = 1
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24044677
Yes, you need those lines.

I'll have a look at the other question.
0
 
LVL 1

Author Closing Comment

by:deshaw
ID: 31564707
thanks
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24047716
You're welcome.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Create high volume marketing opportunities using email signatures with these top 10 DOs and DON'Ts of email signature marketing.
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

759 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

20 Experts available now in Live!

Get 1:1 Help Now