PRB: MAPI_E_LOGON_FAILED when Calling Logon Method

ID: Q178390


The information in this article applies to:


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" %>
    <HTML>
    <BODY LANGUAGE=VBS>
    <%
    Const cStrServer        = "<a valid Exchange Server name>"
    Const cStrMailbox       = "<a valid Mailbox Alias>"
    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 ("cstearns@msn.com")  ' e-mail name to send message to
      objRecips.Resolve
      objFBMess.Send
      objSess.Logoff
    %>
    Mail Sent.
   </BODY>
   </HTML> 

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.


REFERENCES

For more information about the parameters passed to the Logon method, please see the Online Help for Active Messaging and the "Logon Method (Session Object)" topic under Collaboration Data Objects in the Microsoft Developer Network Library (MSDN).

For the latest Knowledge Base articles and other support information on Visual InterDev and Active Server Pages, please see the following page on the Microsoft Technical Support site:

http://support.microsoft.com/support/vinterdev/

Additional query words: Active Messaging Logon Failed ActMsg OleMsg


Keywords          : kbCDO kbNTOS400 kbVisID100 kbWebServer kbGrpASP 
Version           : WINDOWS:1.0,1.1,1.2
Platform          : WINDOWS 
Issue type        : kbprb 

Last Reviewed: May 11, 1999