Microsoft Content Management Server - Error switching to update mode

This is Interesting: Free IT Magazines  
Home > Archive > Microsoft Content Management Server > October 2004 > Error switching to update mode





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Error switching to update mode
GoCMS

2004-10-19, 5: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.
GoCMS

2004-10-19, 5: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 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.

Mei Ying [MVP]

2004-10-20, 2: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]
>.
>

Stefan [MSFT]

2004-10-20, 7:47 am

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...6a/MCMS+2002+-+(complete)+FAQ.htm
MCMS Blog: http://blogs.msdn.com/stefan_gossner/category/4983.aspx
MCMS Sample Code:
http://www.gotdotnet.com/community/...t+S
erver

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.



GoCMS

2004-10-20, 5: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. OnPlaceholderPropertyChanging(Placeholde
r
target, String propertyName, Object& propertyValue) at
Microsoft.ContentManagement.Publishing.Placeholder.BeginWrite(String
propertyName, Object& propertyValue) at
Microsoft.ContentManagement.Publishing.Extensions.Placeholders.HtmlPlaceholder.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!


Stefan [MSFT]

2004-10-20, 5: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...6a/MCMS+2002+-+(complete)+FAQ.htm
MCMS Blog: http://blogs.msdn.com/stefan_gossner/category/4983.aspx
MCMS Sample Code:
http://www.gotdotnet.com/community/...t+S
erver

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!
>
>



GoCMS

2004-10-20, 5: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...6a/MCMS+2002+-+(complete)+FAQ.htm
> MCMS Blog: http://blogs.msdn.com/stefan_gossner/category/4983.aspx
> MCMS Sample Code:
> http://www.gotdotnet.com/community/...t+S
erver

> 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
>
>
>

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com