Solved

Get the contact information using userid

Posted on 2009-03-30
12
212 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
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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Resolve Outlook connectivity issues after moving mailbox to new Exchange 2016 server
Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…

776 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