Solved

Problem retrieving NT account details from CDO

Posted on 2001-06-27
12
581 Views
Last Modified: 2013-11-13
I'm currently writing a Visual Basic component which references CDO for a corporate intranet.

One of the methods of my component will be used to search within the Global Address List for a specific NT user so that I can retrieve their SMTP address & send them emails.

Everything was going fine with writing this component, I can start and log into a MAPI session & gain access to the 'Global Address List' but I am now having problems using one of the MAPI property tags called PR_EMS_AB_ASSOC_NT_ACCOUNT.

I have seen an MSDN article where PR_EMS_AB_ASSOC_NT_ACCOUNT is defined as a
cdo constant - CdoPR_EMS_AB_ASSOC_NT_ACCOUNT with value &H80270102.

Unfortunately, whenever I try & gain access to this property using the 'fields' collection of the AddressEntry object ...

Private Const CdoPR_EMS_AB_ASSOC_NT_ACCOUNT = &H80270102

....

strSID = objAddressEntry.Fields CdoPR_EMS_AB_ASSOC_NT_ACCOUNT).Value

... I get a 'MAPI_E_NOT_FOUND' error. I guess this
is because CDO cannot locate the PR_EMS_AB_ASSOC_NT_ACCOUNT  property within
the AddressEntry object despite the documentation within MSDN which suggests otherwise! Please can somebody tell me what I might be doing wrong, or perhaps there is another way to approach this problem?

Thanks


Jon
0
Comment
Question by:jgianni
12 Comments
 
LVL 22

Expert Comment

by:CJ_S
ID: 6234103
I don't think the value is &H80270102, but &H8027 or &H80270000. Could you try that?

Regards,
CJ
0
 

Author Comment

by:jgianni
ID: 6234281
Thanks. Just tried both of those values but neither worked - received the same error message - MAPI_E_NOT_FOUND.

MSDN documentation *does* state the value for PR_EMS_AB_ASSOC_NT_ACCOUNT as &H80270102 in a number of different places.
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 6234287
Okay,
could you show some source code of yourself? Including the language you are using (I think you are using VB)...just wanna be sure. if you can show some source, I can try and debug.

regards,
CJ
0
 

Author Comment

by:jgianni
ID: 6234407
Private mobjSession As MAPI.Session

'This constant is not defined by CDO (1.2, 1.21)
Private Const CdoPR_EMS_AB_ASSOC_NT_ACCOUNT = &H80270102

Public Function GetSMTPAddress(ByVal vstrUserName As String, ByVal vstrProfileName As String)
   
   ' variable declarations    
    Dim i As Long 'array index
    Dim n As Long ' array index
    Dim objAddressEntry As AddressEntry
    Dim objGlobalAddressList As AddressList
    Dim strSID As String ' sid
     
    ' Log on to a MAPI session
    Call Session_Logon(vstrProfileName)
   
    ' set a reference to the global address list
    Set objGlobalAddressList = GetGlobalAddressList
   
    ' loop through global address list
    For i = 1 To objGlobalAddressList.AddressEntries.Count
   
    Set objAddressEntry = objGlobalAddressList.AddressEntries(i)
       
    ' everything works until here - when I attempt to retrieve the SID
    strSID = objAddressEntry.Fields.Item(CdoPR_EMS_AB_ASSOC_NT_ACCOUNT).Value


0
 
LVL 22

Expert Comment

by:CJ_S
ID: 6234519
I'm kinda ashaimed to ask, but what component did you exactly use that you couldget the MAPI ? I found the CDO libraries for NT and 2000, but neither one of them has those. Next to that i treid the MAPISession control,m which supplied me with almost the same items as you have in your code, but it's not the way to go if I have to follow your way (which I also would like to use).

One thing I found in the documentation is that the PR_EMS_AB_ASSOC_NT_ACCOUNT may not be supported by the underlaying system.

Anyway, before I know the correct reference I cannot debug the code...:-/

regards,
CJ
0
 

Author Comment

by:jgianni
ID: 6234554
Sorry, I omitted a couple of functions that I use to log on to a MAPI session & to retrieve the global address list. Both of these functions work as required, but it's not final code yet so it may be a bit messy.

The CDO library that I am using is 1.21 & I am using Visual Basic 6 SP5.

' Function: Session_Logon_NoDialog
' Purpose: Login to a MAPI session using the given profile name

Private Sub Session_Logon(ByVal vstrProfileName As String)

    On Error GoTo error_olemsg
   
    Set mobjSession = New MAPI.Session
   
    If TypeName(mobjSession) <> "" Then
        mobjSession.Logon vstrProfileName, , False, False
    End If
    Exit Sub

error_olemsg:

    If 1273 = Err Then ' VB4.0: If Err.Number = CdoE_LOGON_FAILED Then
        Err.Raise vbObjectError + 1, "JDWEmailInfo", "Cannot logon: incorrect profile name or password"
        Exit Sub
    End If
   
    Err.Raise vbObjectError + 2, "JDWEmailInfo", "Error " & Str(Err) & ": " & Error$(Err)
    Resume Next
   
End Sub

' Function: GetGlobalAddressList
' Purpose: retrieve the global address list

Private Function GetGlobalAddressList() As AddressList
   
    On Error GoTo err_GetGlobalAddressList
 
    If mobjSession Is Nothing Then
        Err.Raise vbObjectError + 3, "JDWEmailInfo", "No active session has been created."
        Exit Function
    End If
   
    Set GetGlobalAddressList = mobjSession.AddressLists("Global Address List")
   
    Exit Function
 
err_GetGlobalAddressList:
   
    Err.Raise vbObjectError + 5, "JDWEmailInfo", "Unrecoverable Error:" & Err
   
    Exit Function
   
End Function
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 22

Expert Comment

by:CJ_S
ID: 6244220
Been trying to, even installed SP5 but still don't have the MAPI libraries (CDO)...I guess I cannot help / test due to not being able to find the correct reference.

Sorry...

regards,
CJ

(ps. unless you can send me a sample VB project with the reference already set...)
0
 

Author Comment

by:jgianni
ID: 6244926
i think the problem here is to do with an incorrect hex value. i'll give you the points if you can find out what the value is supposed to be!!!

the only msdn documentation that i could find:

"A property tag is a 32-bit number that contains a unique property identifier in bits 16 through 31 and a property type in bits 0 through 15"

remember 'treasure hunt' with anneka rice? this is what this is like!! ;-)
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 6244960
Either that ot it just is not supported.

This is what i found:
Public Const PR_EMS_AB_ASSOC_NT_ACCOUNT = &H80270102

Maybe you find the following link useful:
http://www.outlookexchange.com/Articles/home/outlookcodeexample.asp

They have quite some development articles :-/

Regards,
CJ
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 6244970
Nice comparison btw :-)
0
 
LVL 54

Expert Comment

by:nico5038
ID: 7466858

No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
 - PAQ'd and pts removed
Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

Nic;o)
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 7505173
Finalized as proposed

modulo

Community Support Moderator
Experts Exchange
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
endX challenge 2 63
topping2 challenge 13 80
python question 5 69
Advice in Xamarin 21 47
I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

932 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

19 Experts available now in Live!

Get 1:1 Help Now