Microsoft KB Archive/178390

= PRB: MAPI_E_LOGON_FAILED When Calling Logon Method =

Article ID: 178390

Article Last Modified on 5/2/2006

-

APPLIES TO


 * Microsoft Visual InterDev 1.0 Standard Edition
 * Microsoft Collaboration Data Objects 1.1
 * Microsoft Collaboration Data Objects 1.2

-



This article was previously published under Q178390



SYMPTOMS
You are unable to logon to Exchange Server when calling the logon method of the Collaboration Data Objects (CDO) Session object in an Active Server Page. The following error is generated:

"MAPI_E_LOGON_FAILED"

(NOTE: CDO was formerly known as Active Messaging.)



CAUSE
If an invalid profile name is entered, the error will be generated. The logon method must refer to an existing profile or must create a new profile. In most cases in an ASP, it is best to code the Logon method so that it creates a profile. The profile that is created is temporary and can be deleted when the CDO Session is ended.

In order for an existing profile to be available on the server (where the logon method is executed), the user you are authenticated as when you connect to the IIS machine must be logged on interactively on the server. This occurs because the Logon method searches the HKEY_CURRENT_USER key for the profile being requested. When IIS logs you onto the server, it is simply impersonating your user's security context and your profiles are not loaded into HKEY_CURRENT_USER.



RESOLUTION
The way to create a new profile is to use the following syntax (this code should be on one line): objSess.Logon "", "", False, True, 0, True, "exchangeServerName" & vbLF & "exchangeE-MailName"



STATUS
This behavior is by design.



MORE INFORMATION
To create a Active Messaging ASP page copy, paste the following code into an ASP file: <%@ LANGUAGE="VBSCRIPT" %>   <%   Const cStrServer        = "" Const cStrMailbox      = "" bstrProfileInfo = cStrServer & vbLf & cStrMailbox 'insert a line feed

Set objSess = Server.CreateObject("mapi.session") 'create session objSess.Logon "", "", False, True, 0, True, bstrProfileInfo

Set objFBMess = objSess.Outbox.Messages.Add objFBMess.Subject = "Test Active Messaging" objFBMess.Text = "Greetings from Active Messaging in ASP"

Set objRecips = objFBMess.Recipients objRecips.Add ("someone@microsoft.com") ' e-mail name to send message to      objRecips.Resolve objFBMess.Send objSess.Logoff %>   Mail Sent.  

Steps to Reproduce Behavior
To receive the "MAPI_E_LOGON_FAILED" error, simply change the following line from: objSess.Logon "", "", False, True, 0, True, bstrProfileInfo to: objSess.Logon "dustin hubbard", "", False, True, 0, True This CODE tries to use an existing profile that does not exist, thus generating the "MAPI_E_LOGON_FAILED" error.

