Microsoft KB Archive/328364

= Unhandled Exception When You Try to Reauthenticate a Context to Switch Between Publishing Modes =

Article ID: 328364

Article Last Modified on 10/26/2002

-

APPLIES TO


 * Microsoft Content Management Server 2002

-



This article was previously published under Q328364



SYMPTOMS
If an application calls one of the following methods that Microsoft Content Management Server (MCMS) 2002 components expose against an already authenticated CmsApplicationContext or CmsHttpContext to change the publishing mode or to change the user context The application needs to make reference to following DLLs in Microsoft Content Management Server 2002

- Microsoft.ContentMangement.common.dll - Microsoft.ContentMangement.Publishing.dll - Microsoft.ContentManagment.Publishing.Extensions.Placeholders.dll

cmsContext.AuthenticateAsCurrentUser(...) cmsContext.AuthenticateAsGuest(...) cmsContext.AuthenticateAsUser(...) cmsContext.AuthenticateUsingUserHandle(...) you receive the following exception error message:

An unhandled exception of type 'Microsoft.ContentManagement.Publishing.CmsAuthenticationException' occurred in microsoft.contentmanagement.publishing.dll Additional information: The current session is already logged in. The session must be logged out prior to performing a login.

Although the error message states that the current session must be logged out before you log in again, no API method currently exists to log out.



CAUSE
This behavior is by design.



WORKAROUND
To work around this issue, create a second instance of CmsHttpContext or a second CmsApplicationContext: CmsApplicationContext context = new CmsApplicationContext; Context.AuthenticateAsCurrentUser(PublishingMode.Published );

// // Code block 1 //

context.Dispose; context = new CmsApplicationContext; context. AuthenticateAsCurrentUser( PublishingMode.Update );

// // Code block 2 // Remember that any objects that are retrieved in code block 1 cannot be used in code block 2, so you must re-query those objects in code block 2, as follows: CmsApplicationContext context = new CmsApplicationContext; Context.AuthenticateAsCurrentUser(PublishingMode.Published ); Posting p = ... // some posting. String pGuid = p.Guid; context.Dispose; context = new CmsApplicationContext; context. AuthenticateAsCurrentUser( PublishingMode.Update ); p = context.Searches.GetByGuid( pGuid ) as Posting;

Keywords: kbprb KB328364

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.