Microsoft KB Archive/873203

= You receive a &quot;current user does not have rights to edit the requested item&quot; error message when you save a Web page on Microsoft Content Management Server 2002 =

Article ID: 873203

Article Last Modified on 9/15/2006

-

APPLIES TO


 * Microsoft Content Management Server 2002

-





SYMPTOMS
When you are logged on as an Author to a Microsoft Content Management Server (MCMS) 2002 Web site, you may receive an error message that is similar to the following when you try to save a Web page:

The current user does not have rights to edit the requested item. If you are seeing this exception when a MCMS template is executing, it means that you have removed the CmsAuthorizationModule from the HttpModules section of your web.config. You can only remove this module if: 1. All requests for every MCMS template in the web application will only be accessed by anonymous users 2. Guest access is enabled in MCMS (via the SCA) 3. The MCMS guest user has access to all postings based on templates in the web application If any of these requirements are not met, you MUST register the CmsAuthorizationModule in your web.config.



CAUSE
This problem may occur if you save a Web page that contains a reference to an item that has been deleted from the MCMS Resource Gallery.

Generally, this problem may occur if the MCMS Web site is managed by multiple users in a large organization. For example, when a resource gallery manager deletes an item from the MCMS Resource Gallery, and the Web page that contains the reference to the deleted item is not updated, an author who tries to save any changes that have been made to that Web page receives the error message that is mentioned in the &quot;Symptoms&quot; section.



WORKAROUND
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

To work around this problem, add the following Microsoft Visual C# code to the Global.asax.cs file on the computer that is running MCMS. When you do this, the MCMS workflow is updated automatically to remove any references to items that have been deleted from the Resource Gallery on the MCMS Web site.

To add the VBS code to the Global.asax.cs file, follow these steps:  On the computer that is running MCMS, locate the following folder:



 Right-click Global.asax.cs, click Open With, and then click Notepad. In Notepad, click Find on the Edit menu. In the Find dialog box, type #region Methods, and then click Find Next.  Press ENTER to add a line space after the line that you located in step 4, and then paste the following VBS code. //===================================================================== // Method: DeletedResource(string link) // /// ///    /// This method removes references to deleted items in the Resource Gallery. /// //=====================================================================

private bool DeletedResource(string link) { // Extract the Resource GUID from the URL. string[] splt = link.Split('/'); string GUID = splt[3];

// Create a new context that has administrator rights to see deleted items. CmsApplicationContext appContext = new CmsApplicationContext; appContext.AuthenticateAsUser(&quot;WinNT://servername/cmsAdmin&quot;, &quot;cmsAdminPassword&quot;, PublishingMode.Unpublished);

object o = appContext.Searches.GetByGuid(&quot;{&quot;+GUID+&quot;}&quot;);

// Test whether the item can be deleted. bool isDeleted= false; if (o != null) { isDeleted = ((o is Resource) & (((Resource)o).Path.StartsWith(&quot;/Archive Folder&quot;))); }

// Dispose of the admin context. appContext.Dispose; appContext = null;

// Return the result. return isDeleted; }

private static int FindTag(string text, string tag, int start, string recursecompare) { int pos = text.ToLower.IndexOf(tag.ToLower,start); int check = text.ToLower.IndexOf(recursecompare.ToLower,start+1); if ((check >= 0) & (check < pos)) { check = FindTag(text,tag,check,recursecompare); pos = text.ToLower.IndexOf(tag.ToLower, check+1); } return pos; }

private static string RemoveTagPair(string text, string tag, string endtag, string recursecompare) { int start = text.ToLower.IndexOf(tag.ToLower); int end = -1; while (start >= 0) { end = FindTag(text,endtag,start,recursecompare); if (end > start) text = text.Remove(end,endtag.Length); text = text.Remove(start,tag.Length); start = text.ToLower.IndexOf(tag.ToLower); } return text; }

private string HandleImgAndAttPlaceholderTypes(string propValue) { if (propValue.ToLower.StartsWith(&quot;/nr/rdonlyres&quot;)) { if (DeletedResource(propValue)) { propValue = &quot;&quot; } } return propValue; }

private string HandleImageTags(string propValue) { int start=propValue.ToLower.IndexOf(&quot;= 0) { int end = propValue.IndexOf(&quot;>&quot;,start); if (end > start) { string tag = propValue.Substring(start,end-start+1); int linkStart = tag.ToLower.IndexOf(&quot;\&quot;/nr/rdonlyres&quot;); if (linkStart >= 0) { int linkEnd = tag.IndexOf(&quot;\&quot;&quot;,linkStart+1); if (linkEnd > linkStart) { string linkStr = tag.Substring(linkStart,linkEnd-linkStart+1); if (DeletedResource(linkStr)) { propValue = propValue.Replace(tag,&quot;&quot;); tag = &quot;&quot; } } } start = propValue.ToLower.IndexOf(&quot;= 0) { int end = propValue.IndexOf(&quot;>&quot;,start); if (end > start) { string tag = propValue.Substring(start,end-start+1); int linkStart = tag.ToLower.IndexOf(&quot;\&quot;/nr/rdonlyres&quot;); if (linkStart >= 0) { int linkEnd = tag.IndexOf(&quot;\&quot;&quot;,linkStart+1); if (linkEnd > linkStart) { string linkStr = tag.Substring(linkStart,linkEnd-linkStart+1); if (DeletedResource(linkStr)) { propValue = RemoveTagPair(propValue,tag,&quot;</a>&quot;,&quot;<a&quot;); tag = &quot;&quot; } } } start = propValue.ToLower.IndexOf(&quot;<a &quot;,start+tag.Length); } } return propValue; }

public void CmsPosting_PlaceholderPropertyChanging( Object sender, PropertyChangingEventArgs e ) { string propName = e.PropertyName; string propValue = e.PropertyValue as string; switch (propName) { case &quot;Html&quot; : // handle HtmlPlaceholder ropValue = HandleImageTags(propValue); propValue = HandleAnchorTags(propValue); break; } case &quot;Src&quot; : // handle ImagePlaceholder case &quot;Url&quot; : // handle AttachmentPlaceholder { propValue = HandleImgAndAttPlaceholderTypes(propValue); break; } } e.PropertyValue = propValue; } </li> Save your changes, and then close the file.</li></ol>

<div class="status_section">

STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section.

<div class="moreinformation_section">

MORE INFORMATION
For more information about Microsoft Content Management Server 2002, visit the following Microsoft Web site:

http://www.microsoft.com/cmserver

Keywords: kbprb KB873203

-

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

© Microsoft Corporation. All rights reserved.