Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Use API LookupAccountSid to find outlook phone number

Posted on 2004-08-04
7
Medium Priority
?
370 Views
Last Modified: 2008-03-17
Hi,

I have the below code which works fine but I would also like to get the persons telephone number from outlook.

Option Explicit
Private Declare Function LookupAccountSid Lib "advapi32.dll" Alias "LookupAccountSidA" (ByVal lpSystemName As String, Sid As Any, ByVal name As String, cbName As Long, ByVal ReferencedDomainName As String, cbReferencedDomainName As Long, peUse As Integer) As Long

Public Function LookUpUserByOutlookSID(ByVal strSID As String)
Dim bByte() As Byte
Dim tmp As Integer
Dim i As Integer
Dim ret As Boolean
Dim strDomain As String
Dim iType As Integer
Dim strUserId As String
Dim strFname As String
Dim strLname As String
Dim strEmail As String
Dim strPhone As String
Dim strPersonId As string

On Error GoTo errOutlook:

tmp = Len(strSID) / 2 - 1
ReDim bByte(tmp) As Byte
For i = 0 To tmp - 1
  bByte(i) = CInt("&h" & Mid(strSID, (i * 2) + 1, 2))
Next

strUserId = Space(64)
strDomain = Space(64)

'Get the NT Domain and UserName
ret = LookupAccountSid(vbNullString, bByte(0), strUserId, Len(strName), strDomain, Len(strDomain), iType)
 
strDomain = Left(strDomain, InStr(strDomain, Chr(0)) - 1)
strUserId = Left(strUserId, InStr(strUserId, Chr(0)) - 1)
strPersonId = strUserId

End Function


Thanks for any help

Damien
0
Comment
Question by:damienm
[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
  • 3
7 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 11722598
I don't think that you can get that information that way.  Do you have access to Active Directory services?

Bob
0
 
LVL 2

Author Comment

by:damienm
ID: 11724440
Do you have any code for this?

Thanks,

Damien
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 11725835
Include a reference to Active DS TypeLib.

Dim oUser As IADsUser
           
Set oUser = GetObject("WinNT://<domain/name>,user")

sNumber = oUser.TelephoneNumber

This only works if you use this property in Active Directory.

Bob
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 12469858
Thanks Dan, it is nice sometimes to be the rewardee, instead of the rewarder.

Bob
0

Featured Post

Technology Partners: 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!

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

609 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