Solved

Get the contact information using userid

Posted on 2009-03-30
12
213 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
[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
  • 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
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
 
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Outlook Free & Paid Tools
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
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…
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

740 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