Error switching to update mode
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Microsoft Content Management Server > Error switching to update mode




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Error switching to update mode  
GoCMS


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
10-19-04 10:49 PM

Hey, everyone:
I had some difficulty to get into update mode with windows authentication.
Say I was trying to go into update mode for a published page:

PublishingMode modeBefore = CmsHttpContext.Current.Mode;

WindowsIdentity ident = WindowsIdentity.GetCurrent();
CmsApplicationContext cmsContext = new CmsApplicationContext();
cmsContext.AuthenticateUsingUserHandle(ident.Token, PublishingMode.Update);

PublishingMode modeAfter = CmsHttpContext.Current.Mode;

I didn't get exception, though. But it never succeeded in changing to update
mode. modeBefore and modeAfter is always published.

I'm an admistrator for the site. ( so I should have permissions to all
containers, and also update all postings. ).
The IIS Web site is configured as "Integrated Windows Authentication"
This is what I have in web.config:
<authorization>
<deny users="?" />
</authorization>
<identity impersonate="true" />
<authentication mode="Windows" />

Any ideas of what goes wrong? I'm just running out of ideas. 

Thank you so much in advance.





[ Post a follow-up to this message ]



    RE: Error switching to update mode  
GoCMS


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
10-19-04 10:49 PM

I read some previous posts, and noticed the identity for web page should be:

WindowsIdentity ident = HttpContext.Current.User.Identity as WindowsIdentity
;

Unfortunately, it's still not working after I make the change.

"GoCMS" wrote:

> Hey, everyone:
>   I had some difficulty to get into update mode with windows authenticatio
n.
> Say I was trying to go into update mode for a published page:
>
> PublishingMode modeBefore = CmsHttpContext.Current.Mode;
>
> WindowsIdentity ident = WindowsIdentity.GetCurrent();
> CmsApplicationContext cmsContext = new CmsApplicationContext();
> cmsContext.AuthenticateUsingUserHandle(ident.Token, PublishingMode.Update)
;
>
> PublishingMode modeAfter = CmsHttpContext.Current.Mode;
>
> I didn't get exception, though. But it never succeeded in changing to upda
te
> mode. modeBefore and modeAfter is always published.
>
> I'm an admistrator for the site. ( so I should have permissions to all
> containers, and also update all postings. ).
> The IIS Web site is configured as "Integrated Windows Authentication"
> This is what I have in web.config:
>   <authorization>
>     <deny users="?" />
>    </authorization>
>   <identity impersonate="true" />
>   <authentication mode="Windows" />
>
> Any ideas of what goes wrong? I'm just running out of ideas. 
>
> Thank you so much in advance.





[ Post a follow-up to this message ]



    RE: Error switching to update mode  
Mei Ying [MVP]


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
10-20-04 07:46 AM

Hi

That should work.

Could you post the entire code sample so that we can take
a look at the line that's complaining that you're not in
the update mode?

regards
Mei Ying
---
Blog: http://meiyinglim.blogspot.com
Contact: meiyinglim@hotmail.com
---
>-----Original Message-----
>I read some previous posts, and noticed the identity for
web page should be:
>
>WindowsIdentity ident = HttpContext.Current.User.Identity
as WindowsIdentity;
>
>Unfortunately, it's still not working after I make the
change.
>
>"GoCMS" wrote:
> 
windows authentication.[vbcol=seagreen] 
page:[vbcol=seagreen] 
CmsHttpContext.Current.Mode;[vbcol=seagreen] 
 CmsApplicationContext();[vbcol=seagreen]
 
PublishingMode.Update);[vbcol=seagreen] 
in changing to update[vbcol=seagreen] 
permissions to all[vbcol=seagreen] 
Authentication"[vbcol=seagreen] 
ideas. [vbcol=seagreen] 
>.
>





[ Post a follow-up to this message ]



    Re: Error switching to update mode  
Stefan [MSFT]


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
10-20-04 12:47 PM

Hi,

this is quite simple:
you are authenticating in the CmsApplicationContext (means cmsContext) but
then you are checking the mode of the CmsHttpContext.

Thats not what you need to do.
You need to check the mode of your cmsContext variable.
See here:

> PublishingMode modeBefore = CmsHttpContext.Current.Mode;
>
> WindowsIdentity ident = WindowsIdentity.GetCurrent();
> CmsApplicationContext cmsContext = new CmsApplicationContext();
> cmsContext.AuthenticateUsingUserHandle(ident.Token,
PublishingMode.Update);
>
> PublishingMode modeAfter = cmsContext.Mode;

Cheers,
Stefan.


--
This posting is provided "AS IS" with no warranties, and confers no rights.

MCMS FAQ:
http://download.microsoft.com/downl...>
MCMS+2002+-+(complete)+FAQ.htm
MCMS Blog: http://blogs.msdn.com/stefan_gossner/category/4983.aspx
MCMS Sample Code:
http://www.gotdotnet.com/community/...nagement+Server
MCMS Whitepapers and other docs:
http://blogs.msdn.com/stefan_gossne...2/07/41859.aspx
--------------------------------


"GoCMS" <GoCMS@discussions.microsoft.com> wrote in message
news:440CE324-92A0-4F85-B240-7DD735921504@microsoft.com...
> Hey, everyone:
>   I had some difficulty to get into update mode with windows
authentication.
> Say I was trying to go into update mode for a published page:
>
> PublishingMode modeBefore = CmsHttpContext.Current.Mode;
>
> WindowsIdentity ident = WindowsIdentity.GetCurrent();
> CmsApplicationContext cmsContext = new CmsApplicationContext();
> cmsContext.AuthenticateUsingUserHandle(ident.Token,
PublishingMode.Update);
>
> PublishingMode modeAfter = CmsHttpContext.Current.Mode;
>
> I didn't get exception, though. But it never succeeded in changing to
update
> mode. modeBefore and modeAfter is always published.
>
> I'm an admistrator for the site. ( so I should have permissions to all
> containers, and also update all postings. ).
> The IIS Web site is configured as "Integrated Windows Authentication"
> This is what I have in web.config:
>   <authorization>
>     <deny users="?" />
>    </authorization>
>   <identity impersonate="true" />
>   <authentication mode="Windows" />
>
> Any ideas of what goes wrong? I'm just running out of ideas. 
>
> Thank you so much in advance.







[ Post a follow-up to this message ]



    Re: Error switching to update mode  
GoCMS


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
10-20-04 10:48 PM

Hi, there:
Thank you very much for your reply. I'm posting my complete code ( after
taking Stephan's advice ), and also the exception message:


CmsApplicationContext cmsContext = new CmsApplicationContext();
WindowsIdentity ident = HttpContext.Current.User.Identity as WindowsIdentity
;

bool isError = false;
string temp=string.Empty;
try
{
PublishingMode mode = CmsHttpContext.Current.Mode;
temp= "mode is --" + mode + "<br>";
cmsContext.AuthenticateUsingUserHandle(ident.Token,
publishingMode.Update);
mode = cmsContext.Mode;
temp+= "mode after attemp is -- "+ mode + "<br>";
Posting destPosting =
(Posting)CmsHttpContext.Current.Searches.GetByUrl(destPath);
PlaceholderCollection placeHolders = destPosting.Placeholders;
HtmlPlaceholder destPlaceHolder =
(HtmlPlaceholder)destPosting.Placeholders[name];
temp += "Place Holder Name -- " + destPlaceHolder.Name + "<br>";
destPlaceHolder.Html = myIntendendedHTML;
}
catch(Exception ex)
{
temp += "Error Message -- " + ex.Message + "<br>";
temp += "Exception Source -- " + ex.Source + "<br>";
temp += "Exception Stack Trace -- " + ex.StackTrace + "<br>";
Response.Write(temp);
isError = true;
}

if (!isError)
cmsContext.CommitAll();


Error Message is:

mode is --Published
mode after attemp is -- Update
Place Holder Name -- My Informer
Error Message -- Invalid mode for update. The requested action modifies the
state of an object and can only be performed when the session is in the
'Update' mode.
Exception Source -- Microsoft.ContentManagement.Publishing
Exception Stack Trace -- at
Microsoft.ContentManagement.Publishing.Posting.BeginWrite(Boolean
ignoreMarkForActions) at
Microsoft.ContentManagement.Publishing.Posting.BeginWrite() at
Microsoft.ContentManagement.Publishing.Events.PostingEvents.OnPlaceholderPro
pertyChanging(Placeholder
target, String propertyName, Object& propertyValue) at
Microsoft.ContentManagement.Publishing.Placeholder.BeginWrite(String
propertyName, Object& propertyValue) at
Microsoft.ContentManagement.Publishing.Extensions.Placeholders.HtmlPlacehold
er.set_Html(String
value) at CmsApplication.Templates.Updater.SetDestinationPosting(String
destPath, String name) in
 c:\inetpub\wwwroot\cmsapplication\templa
tes\updater.aspx.cs:line 224


 ****************************************
**************
As you can see, the mode after the attemp is claimed to be "update".
However, setting HtmlPlaceHolder.HTML still gives an "CmsInvalidMode"
exception.
The only thing I suspect, though, is I'm using RadEditorPlaceholder, but I
cast it into an HTMLPlaceholder. But at least, I can get the HTML from that,
it's the setting that gives me the problem.

Thanks again!







[ Post a follow-up to this message ]



    Re: Error switching to update mode  
Stefan [MSFT]


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
10-20-04 10:48 PM

Hi,

you must not use CmsHttpContext.
You just created a new application context but your search uses the
CmsHttpContext.

Please change your code as follows:

>      Posting destPosting =
>                  (Posting)cmsContext.Current.Searches.GetByUrl(destPath);

Cheers,
Stefan.

--
This posting is provided "AS IS" with no warranties, and confers no rights.

MCMS FAQ:
http://download.microsoft.com/downl...>
MCMS+2002+-+(complete)+FAQ.htm
MCMS Blog: http://blogs.msdn.com/stefan_gossner/category/4983.aspx
MCMS Sample Code:
http://www.gotdotnet.com/community/...nagement+Server
MCMS Whitepapers and other docs:
http://blogs.msdn.com/stefan_gossne...2/07/41859.aspx
--------------------------------


"GoCMS" <GoCMS@discussions.microsoft.com> wrote in message
news:A2DA76F9-B08C-4606-9796-C322F5BA1950@microsoft.com...
> Hi, there:
>   Thank you very much for your reply. I'm posting my complete code ( after
> taking Stephan's advice ), and also the exception message:
>
>
> CmsApplicationContext cmsContext = new CmsApplicationContext();
> WindowsIdentity ident = HttpContext.Current.User.Identity as
WindowsIdentity;
>
> bool isError = false;
> string temp=string.Empty;
> try
>     {
>      PublishingMode mode = CmsHttpContext.Current.Mode;
>      temp= "mode is --" + mode + "<br>";
>      cmsContext.AuthenticateUsingUserHandle(ident.Token,
> publishingMode.Update);
>      mode = cmsContext.Mode;
>      temp+= "mode after attemp is -- "+ mode + "<br>";
>      Posting destPosting =
>
(Posting)CmsHttpContext.Current.Searches.GetByUrl(destPath);
>      PlaceholderCollection placeHolders = destPosting.Placeholders;
>      HtmlPlaceholder destPlaceHolder =
>                  (HtmlPlaceholder)destPosting.Placeholders[name];
>      temp += "Place Holder Name -- " + destPlaceHolder.Name + "<br>";
>      destPlaceHolder.Html = myIntendendedHTML;
>     }
>     catch(Exception ex)
>     {
>       temp += "Error Message -- " + ex.Message + "<br>";
>       temp += "Exception Source -- " + ex.Source + "<br>";
>       temp += "Exception Stack Trace -- " + ex.StackTrace + "<br>";
>       Response.Write(temp);
>       isError = true;
>      }
>
>      if (!isError)
>          cmsContext.CommitAll();
>
>
> Error Message is:
>
> mode is --Published
> mode after attemp is -- Update
> Place Holder Name -- My Informer
> Error Message -- Invalid mode for update. The requested action modifies
the
> state of an object and can only be performed when the session is in the
> 'Update' mode.
> Exception Source -- Microsoft.ContentManagement.Publishing
> Exception Stack Trace -- at
> Microsoft.ContentManagement.Publishing.Posting.BeginWrite(Boolean
> ignoreMarkForActions) at
> Microsoft.ContentManagement.Publishing.Posting.BeginWrite() at
>
Microsoft.ContentManagement.Publishing.Events.PostingEvents.OnPlaceholderPro
 pertyChanging(Placeholder
> target, String propertyName, Object& propertyValue) at
> Microsoft.ContentManagement.Publishing.Placeholder.BeginWrite(String
> propertyName, Object& propertyValue) at
>
Microsoft.ContentManagement.Publishing.Extensions.Placeholders.HtmlPlacehold
er.set_Html(String
> value) at CmsApplication.Templates.Updater.SetDestinationPosting(String
> destPath, String name) in
>  c:\inetpub\wwwroot\cmsapplication\templa
tes\updater.aspx.cs:line 224
>
>
>  ****************************************
**************
> As you can see, the mode after the attemp is claimed to be "update".
> However, setting HtmlPlaceHolder.HTML still gives an "CmsInvalidMode"
> exception.
> The only thing I suspect, though, is I'm using RadEditorPlaceholder, but I
> cast it into an HTMLPlaceholder. But at least, I can get the HTML from
that,
> it's the setting that gives me the problem.
>
> Thanks again!
>
>







[ Post a follow-up to this message ]



    Re: Error switching to update mode  
GoCMS


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
10-20-04 10:48 PM

Hi, Stefan:
You're SOOO right!!! Thank you very much! It worked. ))


"Stefan [MSFT]" wrote:

> Hi,
>
> this is quite simple:
> you are authenticating in the CmsApplicationContext (means cmsContext) but
> then you are checking the mode of the CmsHttpContext.
>
> Thats not what you need to do.
> You need to check the mode of your cmsContext variable.
> See here:
> 
> PublishingMode.Update); 
>
> Cheers,
> Stefan.
>
>
> --
> This posting is provided "AS IS" with no warranties, and confers no rights
.
>
> MCMS FAQ:
> http://download.microsoft.com/downl...
a/MCMS+2002+-+(complete)+FAQ.htm
> MCMS Blog: http://blogs.msdn.com/stefan_gossner/category/4983.aspx
> MCMS Sample Code:
> http://www.gotdotnet.com/community/...nagement+Server
> MCMS Whitepapers and other docs:
> http://blogs.msdn.com/stefan_gossne...2/07/41859.aspx
> --------------------------------
>
>
> "GoCMS" <GoCMS@discussions.microsoft.com> wrote in message
> news:440CE324-92A0-4F85-B240-7DD735921504@microsoft.com... 
> authentication. 
> PublishingMode.Update); 
> update 
>
>
>





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 12:44 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register