Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Get the contact information using userid

Posted on 2009-03-30
12
Medium Priority
?
223 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

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

This article describes how to import an Outlook PST file to Office 365 using a third party product to avoid Microsoft's Azure command line tool, saving you time.
This article describes how to import Lotus Notes Contacts into Outlook 2016, 2013, 2010 and 2007 etc. with a few manual steps. You can easily export and migrate Lotus Notes contacts into Microsoft Outlook without having to use any third party tools.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

876 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