<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>[Ryan Rogers]</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/ryanrogers/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/ryanrogers/feed.xml</link>
    <description />
    <lastBuildDate>Wed, 17 Apr 2019 03:27:14 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Setting List Item Permissions Programatically in WSS 3.0/MOSS 2007</title>
      <link>https://docs.microsoft.com/archive/blogs/ryanrogers/setting-list-item-permissions-programatically-in-wss-3-0moss-2007</link>
      <pubDate>Fri, 11 Aug 2006 14:15:00 GMT</pubDate>
      <dc:creator><![CDATA[Ryan Rogers [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ryanrogers/2006/08/11/setting-list-item-permissions-programatically-in-wss-3-0moss-2007/</guid>
      <description><![CDATA[[update: a quick review by one of our SDETs resulted in some good suggestions to make the code below...]]></description>
      <content:encoded><![CDATA[<P><FONT size=2 face=Tahoma>[update: a quick review by one of our SDETs resulted in some good suggestions to make the code below more useable, and I’ve added them to the code below (1.&nbsp; Using GetByType to return the Role Definition rather than specifying the name as a string, thereby working in&nbsp;localized versions other than&nbsp;en-us&nbsp;and 2.&nbsp; checking for unique permissions prior to adding the Role Assignment to the List Item, and breaking permission inheritance if needed – in the case of inherited permissions, the call would otherwise fail).&nbsp; Thanks, Eric!]</FONT></P>
<P><FONT size=2 face=Tahoma>[another quick update:&nbsp; be aware that&nbsp;item-level permissions cannot be set/modified via any out-of-the-box Web Service.&nbsp; The Permissions Web Service (permissions.asmx) can be used to&nbsp;work with permissions on sites or lists, but not items.&nbsp; I hope to create another post sometime relatively soon on creating custom Web Services in WSS 3.0/MOSS 2007, and perhaps I’ll use the code below in the context of a custom web service for that post as well.]</FONT></P>
<P><FONT size=2 face=Tahoma>One of the cool new things in Windows SharePoint Services 3.0 and Microsoft Office SharePoint Server 2007 (get your public beta <A href="http://www.microsoft.com/office/preview/beta/getthebeta.mspx" target=_blank mce_href="http://www.microsoft.com/office/preview/beta/getthebeta.mspx">here</A>)&nbsp;— and make no mistake, there are a lot of cool things to go around in these products — is fine-grained (item-level) security.&nbsp; This was a big big customer wish from the current “v2” versions of the products, and it’s fantastic to see it in the products now.&nbsp; The whole permissions&nbsp;object model&nbsp;has changed (for the better) as a result, and the product team has built in some great flexibility when working with role-based item-level security via the object model.&nbsp; I’ve created a quick sample that shows how to set permissions using the various new OM objects&nbsp;and methodologies, and have included it below as an example that can be expanded to other “permissionable” objects within WSS/MOSS as well.</FONT></P>
<P><FONT size=2 face=Tahoma>In this sample, I’m going&nbsp;set permissions on a individual SPListItem.&nbsp; I’ll create or access a Role Assignment (which essentially represents the user), bind a Role Definition to the Assignment (such as "Full Control", "Contribute," etc.), then add the Role Assignment to the object's RoleAssignments collection.&nbsp; Here’s the code (I’m using a simple C# console app…assume a reference to Microsoft.Sharepoint.dll):</FONT></P>
<P><FONT size=2 face=Tahoma>=====</FONT></P>
<P><FONT size=2 face=Tahoma>using System;<BR>using System.Collections.Generic;<BR>using System.Text;<BR>using Microsoft.SharePoint;</FONT></P>
<P><FONT size=2 face=Tahoma>namespace ListItemPerms<BR>{<BR>&nbsp;&nbsp;&nbsp; class Program<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static void Main(string[] args)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SetListItemPerms();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</FONT></P>
<P><FONT size=2 face=Tahoma>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static void SetListItemPerms()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Get SPWeb object</FONT></P>
<P><FONT size=2 face=Tahoma>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SPSite Site = new SPSite("</FONT><A href="http://%3curl/" mce_href="http://%3curl/"><FONT size=2 face=Tahoma>http://&lt;url</FONT></A><FONT size=2 face=Tahoma>&gt;"); //e.g., "</FONT><A href="http://myserver/mysite" mce_href="http://myserver/mysite"><FONT size=2 face=Tahoma>http://myserver/mysite</FONT></A><FONT size=2 face=Tahoma>"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SPWeb Web = Site.OpenWeb();</FONT></P>
<P><FONT size=2 face=Tahoma>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Get Role Definition from SPWeb</FONT></P>
<P><FONT size=2 face=Tahoma>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SPRoleDefinition RoleDefinition = Web.RoleDefinitions.GetByType(SPRoleType.Administrator); //or whichever SPRoleType you choose</FONT></P>
<P><FONT size=2 face=Tahoma>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Get SPListItem</FONT></P>
<P><FONT size=2 face=Tahoma>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SPList List = Web.Lists["&lt;list name&gt;"]; //e.g., "Announcements"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SPListItem ListItem = List.Items[1];</FONT></P>
<P><FONT size=2 face=Tahoma>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Create new Role Assignment<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Add Role Definition to Role Assignment's Role Definition Bindings</FONT></P>
<P><FONT size=2 face=Tahoma>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SPRoleAssignment RoleAssignment = new SPRoleAssignment("&lt;login name&gt;", //e.g., "MYDOMAIN\UserA" <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "&lt;email address&gt;", //e.g., "</FONT><A href="mailto:usera@example.com" mce_href="mailto:usera@example.com"><FONT size=2 face=Tahoma>usera@example.com</FONT></A><FONT size=2 face=Tahoma>"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "&lt;display name&gt;", //e.g., "User A"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "&lt;notes&gt;"); //e.g., "Here are some notes."</FONT></P>
<P><FONT size=2 face=Tahoma>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RoleAssignment.RoleDefinitionBindings.Add(RoleDefinition);</FONT></P>
<P><FONT size=2 face=Tahoma>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Check for permission inheritance, and break if necessary</FONT></P>
<P><FONT size=2 face=Tahoma>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(!ListItem.HasUniqueRoleAssignments)<BR></FONT><FONT size=2 face=Tahoma>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ListItem.BreakRoleInheritance(true); //pass true to copy role assignments from parent, false to start from scratch<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></P>
<P><FONT size=2 face=Tahoma>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Add Role Assignment to SPListItem's Role Assignment Collection</FONT></P>
<P><FONT size=2 face=Tahoma>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ListItem.RoleAssignments.Add(RoleAssignment);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ListItem.Update();</FONT></P>
<P><FONT size=2 face=Tahoma>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; }<BR>}</FONT></P>
<P><FONT size=2 face=Tahoma>=====</FONT></P>
<P><FONT size=2 face=Tahoma>And that’s that!&nbsp; The user that I specified when creating my new Role Assignment&nbsp;will have Full Control of this single List Item only.&nbsp; :-)</FONT></P>
<P mce_keep="true">&nbsp;</P>]]></content:encoded>
    </item>
    <item>
      <title>Using ASP.NET 2.0 Web Resources in WebParts</title>
      <link>https://docs.microsoft.com/archive/blogs/ryanrogers/using-asp-net-2-0-web-resources-in-webparts</link>
      <pubDate>Tue, 02 May 2006 02:09:00 GMT</pubDate>
      <dc:creator><![CDATA[Ryan Rogers [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ryanrogers/2006/05/02/using-asp-net-2-0-web-resources-in-webparts/</guid>
      <description><![CDATA[[wait…is this a (*gulp*) technical post?&nbsp; sheesh…when’s the last time I actually posted...]]></description>
      <content:encoded><![CDATA[<P><FONT color=#008000 size=2 face=Tahoma>[wait…is this a (*gulp*) <EM>technical</EM> post?&nbsp; sheesh…when’s the last time I actually posted dev/technical content?&nbsp; I was shocked to find that it was </FONT><A href="http://blogs.msdn.com/ryanrogers/archive/2005/03.aspx" mce_href="http://blogs.msdn.com/ryanrogers/archive/2005/03.aspx"><FONT color=#008000 size=2 face=Tahoma>March 2005</FONT></A><FONT color=#008000 size=2 face=Tahoma>, when I posted three fairly useful items — more than a year ago!&nbsp; Well, then…let’s get going, and let’s get something started, eh?]</FONT></P>
<P><FONT size=2 face=Tahoma><STRONG>Web Resources</STRONG></FONT></P>
<P><FONT size=2 face=Tahoma>Way back in the far-distant past, back when all developers had to work with was ASP.NET 1.1 (lo,many ages hence), those developers who wanted to include actual resources — static files such as images, CSS, etc. — with their Web Parts would have to package up the files into an installer package to be included with the Web Part library assembly.&nbsp; Lucky for us, <A href="http://www.asp.net/" mce_href="http://www.asp.net/">ASP.NET 2.0</A> comes with a slick new feature called Web Resources.&nbsp; Web Resources allow resources to be embedded into the assembly and referenced using a special URL (a nice long convoluted querystring, as you’ll see, but easily referenced via some code magic) from within a web project.&nbsp; SharePoint developers working with ASP.NET 2.0 Web Parts — for example, those of you who are using pre-Beta 2 releases of Windows SharePoint Services 3.0 or <A href="http://www.microsoft.com/office/preview/default.mspx" mce_href="http://www.microsoft.com/office/preview/default.mspx">Microsoft Office SharePoint Server 2007</A> (MOSS), and those of you who will be using the Beta 2 release when it shows up someday soon — can take advantage of the new Web Resources feature to wrap up static files into Web Part assemblies and clean up install processes quite a little bit.&nbsp; Web Resources include a number of other cool little tricks that make deploying&nbsp;Web Parts with embedded resources simpler and more robust,&nbsp;as well.&nbsp; Plus, you get to use a cool new thingy — and ain’t that all right, too?</FONT></P>
<P><FONT size=2 face=Tahoma>In this post, I’m going to create a Web Part of negligible utility — well…okay, I’m going to create a totally pointless Web Part that will, nonetheless, demonstrate a couple of things that can be done with Web Resources, and hopefully serve as a starting point for those of you out there that have actual problems to solve. :-)</FONT></P>
<P><FONT size=2 face=Tahoma>All that my Web Part will do is display an image, and have a bit of client-side script that does a rollover effect when you mouse over the image.&nbsp; I’m not even going to get so fancy as to have the image be interesting or functional.&nbsp; We’re just going to have two embedded image resources and one embedded script resource, and have a nice simple Web Part assembly at the end of the day.&nbsp; I’ll be writing a pure ASP.NET 2.0 Web Part — inheriting from the System.Web.UI.WebControls.WebParts.WebPart class — rather than doing anything SharePoint-specific.&nbsp; This will be the recommended approach with WSS 3.0 and MOSS 2007 as well — unless a handful of WSS 2.0/SPS 2003 Web Part relics (V2–style Web Part connections, for example…though I have no idea why you’d use those for a new Web Part in WSS 2.0 or MOSS 2007 when the&nbsp;much richer ASP.NET 2.0 connection framework is available to you)&nbsp;are absolutely necessary, ASP.NET 2.0 Web Parts will be the recommended approach, even for Web Part development that makes use of data in WSS 2.0 or MOSS 2007 via the various APIs.</FONT></P>
<P><FONT size=2 face=Tahoma><STRONG>The Resources</STRONG></FONT></P>
<P><FONT size=2 face=Tahoma>I’m going to use two very simple little button images for the purposes of this example.&nbsp; </FONT></P>
<P><FONT size=2 face=Tahoma>The default button image looks like this:</FONT></P>
<P><FONT size=2 face=Tahoma><IMG border=0 alt="button - default state" src="http://ryanrogers.sts.winisp.net/blog/button.gif" mce_src="http://ryanrogers.sts.winisp.net/blog/button.gif"></FONT></P>
<P><FONT size=2 face=Tahoma>The rollover-state button image looks like this:</FONT></P>
<P><FONT size=2 face=Tahoma><IMG border=0 alt="button - hover state" src="http://ryanrogers.sts.winisp.net/blog/button_hover.gif" mce_src="http://ryanrogers.sts.winisp.net/blog/button_hover.gif"></FONT></P>
<P><FONT size=2 face=Tahoma>The&nbsp;script for doing the rollover is very simple as well:</FONT></P>
<BLOCKQUOTE style="MARGIN-RIGHT: 0px" dir=ltr>
<P><FONT size=2 face=Tahoma>// Initial JScript source code<BR>function RollOver(imageid)<BR>{<BR>&nbsp;&nbsp;&nbsp; document.all.item(imageid).src = 'button_hover.gif';<BR>}<BR>function RollOut(imageid)<BR>{<BR>&nbsp;&nbsp;&nbsp; document.all.item(imageid).src='button.gif';<BR>}</FONT></P></BLOCKQUOTE>
<P><FONT size=2 face=Tahoma>This is saved in a .JS file.&nbsp; In a minute, I’m going to modify that script to include tags that ASP.NET 2.0 will interpret and substitute with URLs to my embedded image resources at runtime, but for now, it’s enough to see that there’s very little magic going on with the script itself.</FONT></P>
<P><FONT size=2 face=Tahoma><STRONG>Getting the&nbsp;Resources into Visual Studio 2005, and Writing the Code</STRONG></FONT></P>
<P><FONT size=2 face=Tahoma><IMG border=0 hspace=10 alt="Screenshot of Project Solution Explorer" vspace=10 align=right src="http://ryanrogers.sts.winisp.net/blog/project_solution_explorer.GIF" mce_src="http://ryanrogers.sts.winisp.net/blog/project_solution_explorer.GIF">In Visual Studio 2005, I create a new Web Control Library project.&nbsp; In my case, I’m going to name it “My.BlogParts.”&nbsp; Next, I’m going to add a new Resource File to the project, which I can do by going the the menu and clicking Project -&gt; Add New Item… and choosing “Resources File.”&nbsp; I’m going to name mine “testres.resx.” [I can also create a project default resources file, but for the purposes of this post, it’s just simpler to create a new one]&nbsp; Once I’ve created it, I can double-click on the testres.resx in Solution Explorer to open up the resources designer.&nbsp; From within the designer, I then choose Add Resource -&gt; Add Existing File… and add my two .GIF images and my .JS script file to the Resources file.&nbsp; In the screenshot on the right, you can see what my project’s Solution Explorer looks like after this has been done.&nbsp; Disregard the additional files in there for now (e.g., RollOver.cs and mykeys.snk), I’ll be discussing them below.&nbsp; However, do note the added “Resources” folder, as it will become important later on.</FONT></P>
<P><FONT size=2 face=Tahoma>For each of the embedded Resource files, I need to set the Build Action for the resource to “Embedded Resource” in the Properties pane for that item.&nbsp; To do so, I simply select the item from within the Resources folder, look at the Properties pane, and select “Embedded Resource” from the Build Action drop-down menu.&nbsp; I can leave “Copy to Output” set to its default, which is “Do not copy.”&nbsp; See the screenshot below:</FONT></P>
<P><FONT size=2 face=Tahoma><IMG border=0 hspace=10 alt="Setting Build Action to " vspace=10 align=left src="http://ryanrogers.sts.winisp.net/blog/resource_embedded.GIF" mce_src="http://ryanrogers.sts.winisp.net/blog/resource_embedded.GIF">Since these are Web Resources, I also need to reference them in my AssemblyInfo.cs file.&nbsp; In this case, here’s the few lines I add:</FONT></P>
<P style="MARGIN-RIGHT: 0px" dir=ltr><FONT size=2 face=Tahoma>&nbsp;&nbsp;&nbsp;&nbsp; [assembly: <FONT color=#008080>WebResource</FONT>(<FONT color=#800000>"My.BlogParts.Resources.button.gif"</FONT>, <FONT color=#800000>"image/gif"</FONT>)]<BR>&nbsp;&nbsp;&nbsp;&nbsp; [assembly: <FONT color=#008080>WebResource</FONT>(<FONT color=#800000>"My.BlogParts.Resources.button_hover.gif"</FONT>, <FONT color=#800000>"image/gif"</FONT>)]<BR>&nbsp;&nbsp;&nbsp;&nbsp; [assembly: <FONT color=#008080>WebResource</FONT>(<FONT color=#800000>"My.BlogParts.Resources.rollover.js"</FONT>, <FONT color=#800000>"text/javascript"</FONT>, PerformSubstitution = <FONT color=#0000ff>true</FONT>)]</FONT></P>
<P><FONT size=2 face=Tahoma>The format of these entries is pretty simple.&nbsp; First param = [Namespace].[Resources Folder].[Resource File Name].&nbsp; Second param = content type.&nbsp; Third (optional) param = PerfomSubstitution (true/false).&nbsp; Because my project, namespace, and assembly will all be named “My.BlogParts,” and my resources folder is named “Resources,” this is pretty easy to figure out:&nbsp; My.BlogParts.Resources.[resource file name].&nbsp; The third, optional, parameter lets me do some super-cool runtime substitution that I’ll explain more in a moment.</FONT></P>
<P><FONT size=2 face=Tahoma>Now that I have my Resources imported into the Project, I’m going to add and write a simple Web Part that will use them.&nbsp; Because I hate default names, I’m going to simply delete the “WebCustomControl1.cs” that was created for me when I created the Project, and add a new Web Custom Control to the Project, named “RollOver.cs.”&nbsp; Visual Studio tries to be nice and adds a bunch of default code into the class file, and in&nbsp;the code snippets below, you might notice that I’ve erased it&nbsp;and started from scratch; for the purposes of this example, though, you could just as well leave all of&nbsp;the default code in the class file and edit the items that I’ve changed and leave the rest since they won’t really hurt anything.</FONT></P>
<P><FONT size=2 face=Tahoma>By default, my web control inherits from the System.Web.UI.WebControls.WebControl class.&nbsp; Because I’m creating a Web Part, I need to change this.&nbsp; First, I’m going to add a using statement at the top of the .cs file:</FONT></P><FONT size=2 face=Tahoma><FONT color=#0000ff size=2>
<BLOCKQUOTE style="MARGIN-RIGHT: 0px" dir=ltr>
<P style="MARGIN-RIGHT: 0px" dir=ltr>using</FONT><FONT size=2> System.Web.UI.WebControls.WebParts;</FONT></P></BLOCKQUOTE>
<P dir=ltr>Next, I simply change my class to inherit from System.Web.UI.WebControls.WebParts.WebPart:</P><FONT color=#0000ff size=2>
<BLOCKQUOTE style="MARGIN-RIGHT: 0px" dir=ltr>
<P style="MARGIN-RIGHT: 0px" dir=ltr>public</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>class</FONT><FONT size=2> </FONT><FONT color=#008080 size=2>RollOver</FONT><FONT size=2> : </FONT><FONT color=#008080 size=2>WebPart<BR></FONT><FONT size=2>{<BR>&nbsp;&nbsp;&nbsp;&nbsp; …</P></BLOCKQUOTE>
<P dir=ltr>Because my Web Part is going to be displaying an image, I’m going to declare a System.Web.UI.WebControls.Image object to the class, e.g.:</P><FONT color=#0000ff size=2>
<BLOCKQUOTE style="MARGIN-RIGHT: 0px" dir=ltr>
<P style="MARGIN-RIGHT: 0px" dir=ltr>public</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>class</FONT><FONT size=2> </FONT><FONT color=#008080 size=2>RollOver</FONT><FONT size=2> : </FONT><FONT color=#008080 size=2>WebPart<BR></FONT><FONT size=2>{<BR>&nbsp;&nbsp;&nbsp;&nbsp; </FONT><FONT color=#0000ff size=2>protected</FONT><FONT size=2> </FONT><FONT color=#008080 size=2>Image</FONT><FONT size=2> imgRoll;<BR></FONT><FONT size=2>&nbsp;&nbsp;&nbsp;&nbsp; …</FONT></P></BLOCKQUOTE>
<P dir=ltr><FONT size=2>Next, I’m going to add an override of the CreateChildControls() method, so that I can add my Image object to the Web Part.&nbsp; This code will be the first to utilize some of the new Web Resource-related methods, and I’ll explain after showing the code:</FONT></P><FONT size=2>
<BLOCKQUOTE style="MARGIN-RIGHT: 0px" dir=ltr>
<P dir=ltr></FONT><FONT color=#0000ff size=2>protected</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>override</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>void</FONT><FONT size=2> CreateChildControls()<BR>{</FONT><FONT color=#008080 size=2><BR>&nbsp;&nbsp;&nbsp;&nbsp; ClientScriptManager</FONT><FONT size=2> cs = Page.ClientScript;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp; imgRoll = </FONT><FONT color=#0000ff size=2>new</FONT><FONT size=2> </FONT><FONT color=#008080 size=2>Image</FONT><FONT size=2>();<BR>&nbsp;&nbsp;&nbsp;&nbsp; imgRoll.ImageUrl = cs.GetWebResourceUrl(</FONT><FONT color=#0000ff size=2>this</FONT><FONT size=2>.GetType(),<BR></FONT><FONT color=#800000 size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "My.BlogParts.Resources.button.gif"</FONT><FONT size=2>);<BR>&nbsp;&nbsp;&nbsp;&nbsp; imgRoll.Attributes.Add(</FONT><FONT color=#800000 size=2>"onMouseOver"</FONT><FONT size=2>, </FONT><FONT color=#800000 size=2>"RollOver(this.id)"</FONT><FONT size=2>);<BR>&nbsp;&nbsp;&nbsp;&nbsp; imgRoll.Attributes.Add(</FONT><FONT color=#800000 size=2>"onMouseOut"</FONT><FONT size=2>, </FONT><FONT color=#800000 size=2>"RollOut(this.id)"</FONT><FONT size=2>);<BR>&nbsp;&nbsp;&nbsp;&nbsp; imgRoll.ID = </FONT><FONT color=#800000 size=2>"myimage2"</FONT><FONT size=2>;</P>
<P style="MARGIN-RIGHT: 0px" dir=ltr>&nbsp;&nbsp;&nbsp;&nbsp; Controls.Add(imgRoll);<BR>}</P></BLOCKQUOTE></FONT>
<P dir=ltr><FONT size=2>So, from the perspective of Web Part development, I first instantiate a new Image object, assign some attributes, and add it to the Web Part’s “Controls” collection.&nbsp; You’ll note that I’m adding some attributes to&nbsp;specify onMouseOut and onMouseOver&nbsp;script&nbsp;calls.&nbsp; The interesting stuff, though,&nbsp;is the ClientScriptManager object&nbsp;and GetWebResourceURL() method.&nbsp; I’m not going to go into detail about these, since you can read about each of them <A href="http://msdn2.microsoft.com/en-us/library/system.web.ui.clientscriptmanager_members(VS.80).aspx" mce_href="http://msdn2.microsoft.com/en-us/library/system.web.ui.clientscriptmanager_members(VS.80).aspx">here</A> and <A href="http://msdn2.microsoft.com/en-us/library/system.web.ui.clientscriptmanager.getwebresourceurl.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/system.web.ui.clientscriptmanager.getwebresourceurl.aspx">here</A>, and I’m sure elsewhere as well.&nbsp; It’s enough to point out that once I’ve created a ClientScriptManager object, I can use its GetWebResourceURL() method to return the URL to an embedded resource.&nbsp; I pass it two parameters:&nbsp; the resource type (I can just use this.GetType() in C# to return the type) and the name of the resource.&nbsp; I need to specify the name of the web resource here like I specified it in AssemblyInfo.cs — [Namespace].[Resources folder].[Resource File Name].</FONT></P>
<P dir=ltr><FONT size=2>OK, two more code steps:&nbsp; I need to get my script included in the target page, and I need to render the Image control.&nbsp; For the former, I override the OnPreRender event, because I want my script loaded before the page loads (so that it is available to my Web Part once it renders).&nbsp; I use the ClientScriptManager’s RegisterClientScriptInclude() method to add my script as an include, passing the type (again, using this.GetType() in C#), the resource name, and the URL of the resource (the last of which I obtain using GetWebResourceURL() again).</FONT></P><FONT size=2><FONT color=#0000ff size=2>
<BLOCKQUOTE style="MARGIN-RIGHT: 0px" dir=ltr>
<P>protected</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>override</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>void</FONT><FONT size=2> OnPreRender(</FONT><FONT color=#008080 size=2>EventArgs</FONT><FONT size=2> e)<BR>{<BR></FONT><FONT color=#008080 size=2>&nbsp;&nbsp;&nbsp;&nbsp; ClientScriptManager</FONT><FONT size=2> cs = Page.ClientScript;<BR>&nbsp;&nbsp;&nbsp;&nbsp; cs.RegisterClientScriptInclude(</FONT><FONT color=#0000ff size=2>this</FONT><FONT size=2>.GetType(), </FONT><FONT color=#800000 size=2>"rollover"</FONT><FONT size=2>, cs.GetWebResourceUrl(</FONT><FONT color=#0000ff size=2>this</FONT><FONT size=2>.GetType(),<BR></FONT><FONT color=#800000 size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "My.BlogParts.Resources.rollover.js"</FONT><FONT size=2>));<BR>}</FONT></P></BLOCKQUOTE>
<P>For the latter — rendering the Image control — I simply override RenderContents() (if you haven’t removed all of the code that Visual Studio created for you, one already exists, and you can just edit the contents), and render it like I would in WSS 2.0/SPS 2003:</P><FONT color=#0000ff size=2>
<BLOCKQUOTE style="MARGIN-RIGHT: 0px" dir=ltr>
<P>protected</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>override</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>void</FONT><FONT size=2> RenderContents(</FONT><FONT color=#008080 size=2>HtmlTextWriter</FONT><FONT size=2> output)<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp; EnsureChildControls();<BR></FONT><FONT color=#0000ff size=2>&nbsp;&nbsp;&nbsp;&nbsp; this</FONT><FONT size=2>.imgRoll.RenderControl(output);<BR>}</FONT></P></BLOCKQUOTE>
<P><FONT size=2><STRONG>Using PerformSubstition to Replace Placeholders with URLs at Runtime</STRONG></FONT></P>
<P><FONT size=2>One last thing.&nbsp; The script file that I outlined earlier included hard-coded values for URLs, e.g.:</FONT></P>
<BLOCKQUOTE style="MARGIN-RIGHT: 0px" dir=ltr>
<P><FONT size=2>document.all.item(imageid).src='button.gif';</FONT></P></BLOCKQUOTE>
<P><FONT size=2>This won’t work for an embedded Web Resource, of course (this would look for a static button.gif file in the current directory).&nbsp; Thankfully, ASP.NET 2.0 Web Resources includes a solution, via PerformSubstitution.&nbsp; When I referenced my Web Resources in AssemblyInfo.cs, I included “PerformSubstituion = true” for my embedded .JS script file.&nbsp; This tells ASP.NET 2.0 to look for “tags” (my phrase) in the embedded file, and replace them at runtime.&nbsp; I’m then able to add tags referencing additional embedded Web Resources.&nbsp; Because I’m embedding my image files, I’ll modify my script to include tags so that at runtime, the URL is replaced with the embedded Web Resource URL for the images, e.g.:</FONT></P>
<BLOCKQUOTE style="MARGIN-RIGHT: 0px" dir=ltr>
<P><FONT size=2>// JScript source code<BR>function RollOver(imageid)<BR>{<BR>&nbsp;&nbsp;&nbsp; document.all.item(imageid).src = '&lt;%=WebResource("My.BlogParts.Resources.button_hover.gif")%&gt;';<BR>}<BR>function RollOut(imageid)<BR>{<BR>&nbsp;&nbsp;&nbsp; document.all.item(imageid).src='&lt;%=WebResource("My.BlogParts.Resources.button.gif")%&gt;';<BR>}</P></BLOCKQUOTE></FONT>
<P>The format should look pretty familiar by now — [Namespace].[Resources Folder].[Resource File Name].&nbsp; At runtime, those tags will be replaced by the Web Resource URL for each of the embedded images.</P>
<P><STRONG>Build and Deploy the Web Part</STRONG></P>
<P>That’s it for code.&nbsp; Because I’m going to deploy my Web Part to the GAC for the purposes of this example, I strong-name the assembly when I build it (in this case, by going to the menu and selecting Project –&gt; [Project Name] Properties…, selecting the “Signing” tab, checking “Sign the assembly,” and creating a new strong name key file using the option in the drop-down menu).&nbsp; The resulting assembly contains my Web Part and all of the resources it needs — I can deploy the assembly alone, and don’t have to package up the static files along with it for installation.</P>
<P>I’m not going to get into Web Part deployment in this post, but those are all of the steps needed to create a simple Web Part that uses embedded image and script resources to perform a simple little rollover/hover image effect.&nbsp; I’ve posted the full source code and image files in a <A href="http://ryanrogers.sts.winisp.net/dl/My.BlogParts.zip" mce_href="http://ryanrogers.sts.winisp.net/dl/My.BlogParts.zip">ZIP archive</A> if you’re interested.</P>
<P>Happy coding!</FONT></FONT></FONT></P>]]></content:encoded>
    </item>
    <item>
      <title>On Site Definitions, or How I Learned to Stop Worrying and Love KB 898631</title>
      <link>https://docs.microsoft.com/archive/blogs/ryanrogers/on-site-definitions-or-how-i-learned-to-stop-worrying-and-love-kb-898631</link>
      <pubDate>Sat, 04 Jun 2005 03:09:00 GMT</pubDate>
      <dc:creator><![CDATA[Ryan Rogers [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ryanrogers/2005/06/04/on-site-definitions-or-how-i-learned-to-stop-worrying-and-love-kb-898631/</guid>
      <description><![CDATA[By now, the commotion surrounding KB 898631 has died down somewhat, after an inital explosion of...]]></description>
      <content:encoded><![CDATA[<P><FONT size=2 face=Tahoma>By now, the commotion surrounding KB <A href="http://support.microsoft.com/?id=898631" mce_href="http://support.microsoft.com/?id=898631">898631</A> has died down somewhat, after an inital explosion of commentary.&nbsp; Serge's <A href="http://weblogs.asp.net/soever/archive/2005/05/12/406535.aspx" mce_href="http://weblogs.asp.net/soever/archive/2005/05/12/406535.aspx">first post</A> seemed to be the initial spark that lit the tinder, and I suspect that his was but the most immediately recognizable voice and certainly the loudest, where many other voices and opinions remain OTW (off-the-web) and therefore unnoticed.&nbsp; It's undeniably a topic that has made a lot of waves, both outside and inside Microsoft walls.</FONT></P>
<P><FONT size=2 face=Tahoma>I'll go ahead and open myself up for criticism, I suppose, by noting that I drafted the initial "informal" version of these rules, which then became the basis for the KB article.&nbsp; The "rules" themselves have almost all been in place as part of the SDK in various places for quite a while but have been more or less A) unnoticed or B) ignored.&nbsp; Serge's <A href="http://weblogs.asp.net/soever/archive/2005/05/26/408948.aspx" mce_href="http://weblogs.asp.net/soever/archive/2005/05/26/408948.aspx">second post</A> on the topic includes a few lines from an email I wrote, which essentially says the same thing:</FONT></P>
<P><FONT size=2 face=Tahoma>"The statement that appears to be making the most waves on Serge's blog -- "You modify a custom site definition or a custom area definition after you deploy the custom site definition or the custom area definition" -- was already in place in the SDK (</FONT><A href="http://msdn.microsoft.com/library/en-us/spptsdk/html/tsovGuidelinesCustomTemplates_SV01018815.asp?frame=true" mce_href="http://msdn.microsoft.com/library/en-us/spptsdk/html/tsovGuidelinesCustomTemplates_SV01018815.asp?frame=true"><FONT size=2 face=Tahoma>http://msdn.microsoft.com/library/en-us/spptsdk/html/tsovGuidelinesCustomTemplates_SV01018815.asp?frame=true</FONT></A><FONT size=2 face=Tahoma>) before this KB article was published; this KB article was, more or less, a reminder and summary of the "rules" that had already been defined in various places throughout the SDK."</FONT></P>
<P><FONT size=2 face=Tahoma>So, a couple of things to point out, here.&nbsp; First, although these things were already extant in the SDK, they were NOT well-placed, well-organized, or in any way easy to comprehend in a unified way.&nbsp; The mention of site definition rules were scattered throughout the SDK in a number of different places -- the one above being just one of several.&nbsp; Additionally, when discussing site definitions, the SDK previously used language -- which we've since changed -- that was simply not forceful enough (e.g., using the term "recommendations" rather than "requirements").&nbsp; The purpose of the SDK language changes and the article above was to bring all of the site definition "Rules and Regulations" into a simple, easy-to-understand article that would lay down the facts once and for all (or...at least, for the time being).&nbsp; </FONT></P>
<P><FONT size=2 face=Tahoma>Because we wanted this to be the "official" statement on site definition rules, we did what good Microsoft employees do;&nbsp; we argued about it -- sometimes loudly :) -- amongst ourselves.&nbsp; Then, we got final word buyoff from the product group folks who are ultimately responsible for implementing these things.&nbsp; It's fair to say that there were very strong and vocal arguments about nearly all of these items, but particularly about the item above, "changing a site or area definition after it has been deployed."&nbsp; Lots and lots of people love being able to make a change to a central site definition and have that change automatically populated throughout any sites that have been created using that definition.&nbsp; No doubt, that's a cool thing.</FONT></P>
<P><FONT size=2 face=Tahoma>Unfortunately, it is not something that the product was designed to do.&nbsp; The folks who wrote and designed this product don't like the idea, and have strong enough concerns about the stability of the product when used in such a way that they've been willing to continue to tell us that it is unsupported even in the face of fairly strong external *and* internal pressures.&nbsp; We decided that we'd rather have the SharePoint community upset about the support policy itself than have folks in the SharePoint community find themselves in unsupported scenarios or with unexpected and potentially unsupported problems precisely because Microsoft hadn't done a good enough job getting out the message about supportability where site and/or area definitions are concerned.</FONT></P>
<P><FONT size=2 face=Tahoma>All that being the case, what some other of my colleagues and MVPs have said is true;&nbsp; there remain supported ways to make changes to a wide number of sites in a SharePoint deployment -- the object model/API being the foremost among them.&nbsp; Is this a perfect answer?&nbsp; Of course not!&nbsp; Making a global change by modifying a line or two in the ONET.XML file sure is easier than writing 100 lines of OM/API code to do the same thing.&nbsp; Anyone who has ever tried to do something as conceptually simple as copy a list from one site to another with the OM/API knows that simplicity is in the eye of...well, no one.&nbsp; But we are assured that if any problems occur when running our OM/API code, it will be 100% supportable -- and that, Martha would say, is a good thing.</FONT></P>
<P><FONT size=2 face=Tahoma>Here's hoping the situation improves in future versions of the product.&nbsp; :)</FONT></P>
<P><FONT size=2 face=Tahoma>-R</FONT></P>]]></content:encoded>
    </item>
    <item>
      <title>Posts from the Past</title>
      <link>https://docs.microsoft.com/archive/blogs/ryanrogers/posts-from-the-past</link>
      <pubDate>Wed, 01 Jun 2005 00:59:00 GMT</pubDate>
      <dc:creator><![CDATA[Ryan Rogers [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ryanrogers/2005/06/01/posts-from-the-past/</guid>
      <description><![CDATA[When http://blogs.msdn.com switched from Scott Watermasysk's .Text to Community Server for blogging,...]]></description>
      <content:encoded><![CDATA[<P class="postfont">When <A href="" class="postfont">http://blogs.msdn.com</A> switched from Scott Watermasysk's .Text to Community Server for blogging, much of the formatting of my previous posts was completely crushed, as was the ability to control which posts appeared on the front page of my blog.&nbsp; So, to work around the latter while still allowing the former to be viewable even in their crippled format, I've put together a list here in an Article post which I'll link from the front page of my blog.&nbsp; My apologies for the lousy formatting, particularly where the Community Server changes have made nonsense of code.</P>
<P class="postfont">I'll add to this list from this point on, unless a better solution comes by way of new functionality on Community Server.&nbsp; </P>
<P class="postfont">Newest posts are at the top.</P>
<P class="postfont">=====</P>
<UL>
<LI><a href="http://blogs.msdn.com/ryanrogers/archive/2005/03/22/400712.aspx" class="postfont">CopyCat: Using Built-in WebServices to Copy Document Library Permissions Across Servers</A>
<LI><a href="http://blogs.msdn.com/ryanrogers/archive/2005/03/22/400700.aspx" class="postfont">Alert Me: Parameters Passed to SearchAlertType.GetAlertCreationLink()</A>
<LI><a href="http://blogs.msdn.com/ryanrogers/archive/2005/03/22/400661.aspx" class="postfont">Finding Ghosts: Programmatically Determining Ghosted/Unghosted State</A>
<LI><a href="http://blogs.msdn.com/ryanrogers/archive/2005/02/23/379100.aspx" class="postfont">Drawing the Curtain: Removing Access to the Site Settings Page for non-Administrative Users</A>
<LI><a href="http://blogs.msdn.com/ryanrogers/archive/2005/02/10/370866.aspx" class="postfont">What's on the Menu? - How to Remove Items from a Document Library Drop-down Menu</A>
<LI><a href="http://blogs.msdn.com/ryanrogers/archive/2004/12/08/278603.aspx" class="postfont">UPDATE: Get your MSSQLFT Documentation While it's Hot (and I'll bet it is)</A>
<LI><a href="http://blogs.msdn.com/ryanrogers/archive/2004/10/08/240050.aspx" class="postfont">Expanding Horizons: Restrict a Customized Search to an Individual, New, Programatically-Created Content Source</A>
<LI><a href="http://blogs.msdn.com/ryanrogers/archive/2004/10/08/239968.aspx" class="postfont">Adding New List Items Using the Lists.asmx Web Service</A>
<LI><a href="http://blogs.msdn.com/ryanrogers/archive/2004/07/15/184594.aspx" class="postfont">So, DoesUserHavePermissions() or Not?</A>
<LI><a href="http://blogs.msdn.com/ryanrogers/archive/2004/07/09/178900.aspx" class="postfont">MSSQLFT Syntax School -- How to Get Ahead in Search</A>
<LI><a href="http://blogs.msdn.com/ryanrogers/archive/2004/07/09/178466.aspx" class="postfont">Creating a Modal Dialog "Chooser" Tool Part</A></LI></UL>]]></content:encoded>
    </item>
    <item>
      <title>Test</title>
      <link>https://docs.microsoft.com/archive/blogs/ryanrogers/test</link>
      <pubDate>Fri, 13 May 2005 18:08:00 GMT</pubDate>
      <dc:creator><![CDATA[Ryan Rogers [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ryanrogers/2005/05/13/test/</guid>
      <description><![CDATA[Test]]></description>
      <content:encoded><![CDATA[Test]]></content:encoded>
    </item>
    <item>
      <title>CopyCat: Using Built-in WebServices to Copy Document Library Permissions Across Servers</title>
      <link>https://docs.microsoft.com/archive/blogs/ryanrogers/copycat-using-built-in-webservices-to-copy-document-library-permissions-across-servers</link>
      <pubDate>Tue, 22 Mar 2005 20:54:00 GMT</pubDate>
      <dc:creator><![CDATA[Ryan Rogers [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ryanrogers/2005/03/22/copycat-using-built-in-webservices-to-copy-document-library-permissions-across-servers/</guid>
      <description><![CDATA[&nbsp; 
Here's a sample console application written in C# which will copy the permissions from one...]]></description>
      <content:encoded><![CDATA[&nbsp; 
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">Here's a sample console application written in C# which will copy the permissions from one document library to another using the built-in Permissions.asmx WebService.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Note that this sample does not account for cross-domain use, etc.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>This will *only* work if the same users exist on the destination.&nbsp; Overall, this is a fairly rough sample, but it covers some good material, so I thought I'd go ahead and post here.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>:)</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">The sample does the following:</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 10pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">-Gets the current destination list permissions using the web service on the destination site</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">-Removes the current destination list permissions using the web service on the destination site</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">-Gets the source list permissions using the web service on the source site</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">-Sets the destination list permissions using the web service on the destination site</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 10pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">This project will require adding a Web Reference -- to the Permissions web service on <SPAN style="FONT-STYLE: italic">any </SPAN>machine (the URL will be overwritten in the code) -- in the VC# project.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Adding the Web Reference should add standard references to System.Web.Services, System.XML, and System.Data.<BR></P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">Two notes on this sample:</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">1) There is little error handling. </P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"><SPAN style="FONT-SIZE: 8pt">2)<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>We cannot remove or add implicit members (Administrator, Guest) of a list. These members are automatically added when a list is created, and are not controlled by the user; as such, they can not be programmatically modified.</SPAN></P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 10pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">=====</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">using System;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">using System.Xml;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">using System.Diagnostics;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">namespace CopyDocLibPermissions</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">{</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">public class AddWithWS</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">{</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">[STAThread]</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">static void Main(string[] args)</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">{</P>
<P style="MARGIN: 0in 0in 0in 1.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 4">string sSourceSiteURL = "<A href="http://%3cserver%3e/sites/%3csite1%3e" mce_href="http://%3cserver%3e/sites/%3csite1%3e">http://&lt;server&gt;/sites/&lt;site1&gt;</A>"; //TODO: modify</P>
<P style="MARGIN: 0in 0in 0in 1.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 4">string sSourceList = "MySourceList"; //TODO: modify</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">string sDestSiteURL = "<A href="http://%3cserver%3e/sites/%3csite2%3e" mce_href="http://%3cserver%3e/sites/%3csite2%3e">http://&lt;server&gt;/sites/&lt;site2&gt;</A>"; //TODO: modify</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">string sDestList = "MyDestinationList"; //TODO: modify</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">int iReturn = CopyPermissions(sSourceSiteURL, sSourceList, sDestSiteURL, sDestList);</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">Console.ReadLine();</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">}</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">static int CopyPermissions(string SourceSite, string SourceList, string DestSite, string DestList)</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">{ </P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">//get permissions from destination list</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">System.Xml.XmlNode xDestPerms = GetPermissions(DestSite, DestList);</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">//remove existing permissions from destination list</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">RemovePermissions(DestSite, DestList, xDestPerms);</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">//get source list permissions</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">System.Xml.XmlNode xSourcePerms = GetPermissions(SourceSite, SourceList);</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">//add source list permissions to destination list</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">SetPermissions(DestSite, DestList, xSourcePerms);</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">Console.WriteLine("==COMPLETE!==\n");</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">return 0;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">}</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">static XmlNode GetPermissions(string URL, string ListName)</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">{</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">URL += "/_vti_bin/Permissions.asmx";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">localhost.Permissions oPermissionsService = new localhost.Permissions();</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">oPermissionsService.Url = URL;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">oPermissionsService.Credentials = System.Net.CredentialCache.DefaultCredentials;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">try</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">{</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">XmlNode oNode = oPermissionsService.GetPermissionCollection(ListName, "List");</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">return oNode;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">}</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">catch(System.Exception exGet)</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">{</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">Console.WriteLine("Error Getting Permissions!");</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">Debug.WriteLine(exGet.ToString());</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">return null;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">}</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">}</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">static bool RemovePermissions(string URL, string ListName, XmlNode Permissions)</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">{</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">URL += "/_vti_bin/Permissions.asmx";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">localhost.Permissions oPermissionsService = new localhost.Permissions();</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">oPermissionsService.Url = URL;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">oPermissionsService.Credentials = System.Net.CredentialCache.DefaultCredentials;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">XmlNodeList xNL = Permissions.FirstChild.ChildNodes;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">string sPerm = "";</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">string sIsUser = "";</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">string sName = "";</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">string sType = "";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">for(int i=0;i&lt;xNL.Count;i++)</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">{</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">sIsUser = xNL[i].Attributes["MemberIsUser"].Value.ToString().ToUpper();</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">if(sIsUser == "TRUE")</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">{</P>
<P style="MARGIN: 0in 0in 0in 1.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 4">//is user</P>
<P style="MARGIN: 0in 0in 0in 1.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 4">sName = xNL[i].Attributes["UserLogin"].Value.ToString();</P>
<P style="MARGIN: 0in 0in 0in 1.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 4">sType = "user";</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">}</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">else</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">{</P>
<P style="MARGIN: 0in 0in 0in 1.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 4">sPerm = xNL[i].OuterXml.ToString();</P>
<P style="MARGIN: 0in 0in 0in 1.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 4">if(sPerm.IndexOf("RoleName") &gt; 0)</P>
<P style="MARGIN: 0in 0in 0in 1.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 4">{</P>
<P style="MARGIN: 0in 0in 0in 2in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 5">//is Role</P>
<P style="MARGIN: 0in 0in 0in 2in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 5">sName = xNL[i].Attributes["RoleName"].Value.ToString();</P>
<P style="MARGIN: 0in 0in 0in 2in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 5">sType = "role";</P>
<P style="MARGIN: 0in 0in 0in 1.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 4">}</P>
<P style="MARGIN: 0in 0in 0in 1.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 4">else</P>
<P style="MARGIN: 0in 0in 0in 1.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 4">{</P>
<P style="MARGIN: 0in 0in 0in 2in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 5">//is group</P>
<P style="MARGIN: 0in 0in 0in 2in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 5">sName = xNL[i].Attributes["GroupName"].Value.ToString();</P>
<P style="MARGIN: 0in 0in 0in 2in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 5">sType = "group";</P>
<P style="MARGIN: 0in 0in 0in 1.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 4">}</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">}</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">try</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">{</P>
<P style="MARGIN: 0in 0in 0in 1.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 4">oPermissionsService.RemovePermission(ListName, "List", sName, sType);</P>
<P style="MARGIN: 0in 0in 0in 1.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 4">Console.WriteLine("Permission Removed: {0}", sName);</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">}</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">catch(System.Exception exRemove)</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">{</P>
<P style="MARGIN: 0in 0in 0in 1.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 4">Console.WriteLine("Can't Remove Permission: {0}",sName);</P>
<P style="MARGIN: 0in 0in 0in 1.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 4">Debug.WriteLine(exRemove.ToString());</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">}</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">}</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">return true;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">}</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">static bool SetPermissions(string URL, string ListName, XmlNode Permissions)</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">{</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">URL += "/_vti_bin/Permissions.asmx";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">localhost.Permissions oPermissionsService = new localhost.Permissions();</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">oPermissionsService.Url = URL;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">oPermissionsService.Credentials = System.Net.CredentialCache.DefaultCredentials;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">XmlNodeList xNL = Permissions.FirstChild.ChildNodes;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">string sPerm = "";</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">string sIsUser = "";</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">string sName = "";</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">string sType = "";</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">int iMask = 0;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">for(int i=0;i&lt;xNL.Count;i++)</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">{</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">sIsUser = xNL[i].Attributes["MemberIsUser"].Value.ToString().ToUpper();</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">iMask = Int32.Parse(xNL[i].Attributes["Mask"].Value);</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">if(sIsUser == "TRUE")</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">{</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">//is user</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">sName = xNL[i].Attributes["UserLogin"].Value.ToString();</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">sType = "user";</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">}</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">else</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">{</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">sPerm = xNL[i].OuterXml.ToString();</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">if(sPerm.IndexOf("RoleName") &gt; 0)</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">{</P>
<P style="MARGIN: 0in 0in 0in 1.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 4">//is Role</P>
<P style="MARGIN: 0in 0in 0in 1.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 4">sName = xNL[i].Attributes["RoleName"].Value.ToString();</P>
<P style="MARGIN: 0in 0in 0in 1.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 4">sType = "role";</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">}</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">else</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">{</P>
<P style="MARGIN: 0in 0in 0in 1.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 4">//is group</P>
<P style="MARGIN: 0in 0in 0in 1.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 4">sName = xNL[i].Attributes["GroupName"].Value.ToString();</P>
<P style="MARGIN: 0in 0in 0in 1.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 4">sType = "group";</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">}</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">}</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">try</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">{</P>
<P style="MARGIN: 0in 0in 0in 1.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 4">oPermissionsService.AddPermission(ListName, "List", sName, sType, iMask);</P>
<P style="MARGIN: 0in 0in 0in 1.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 4">Console.WriteLine("Permission Added: {0}", sName);</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">}</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">catch(System.Exception exAdd)</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">{</P>
<P style="MARGIN: 0in 0in 0in 1.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 4">Console.WriteLine("Can't Add Permission: {0}",sName);</P>
<P style="MARGIN: 0in 0in 0in 1.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 4">Debug.WriteLine(exAdd.ToString());</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">}</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">}</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">return true;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">}</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">}</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">}</P>]]></content:encoded>
    </item>
    <item>
      <title>Alert Me: Parameters Passed to SearchAlertType.GetAlertCreationLink()</title>
      <link>https://docs.microsoft.com/archive/blogs/ryanrogers/alert-me-parameters-passed-to-searchalerttype-getalertcreationlink</link>
      <pubDate>Tue, 22 Mar 2005 20:17:00 GMT</pubDate>
      <dc:creator><![CDATA[Ryan Rogers [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ryanrogers/2005/03/22/alert-me-parameters-passed-to-searchalerttype-getalertcreationlink/</guid>
      <description><![CDATA[&nbsp; 
The SDK documents the GetAlertCreationLink() method as part of every class in the...]]></description>
      <content:encoded><![CDATA[&nbsp; 
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">The SDK documents the GetAlertCreationLink() method as part of every class in the Microsoft.SharePoint.Portal.Alerts namespace.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>However, if we want to utilize this method in some way -- for example, to generate our own "Alert Me" link on a custom search page -- the documentation is not quite sufficient.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Here's how the SDK defines the parameters passed to GetAlertCreationLink for the SearchAlertType class:</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2"><SPAN style="FONT-STYLE: italic">strQueryWhereClause<SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN></SPAN>WHERE clause for the search query this alert describes.</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2"><SPAN style="FONT-STYLE: italic">strViewThisSearchResultsURL<SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN></SPAN>URL for the search result that this alert describes.</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2"><SPAN style="FONT-STYLE: italic">strSuggestedTitle<SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN></SPAN>Suggested link text.</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2"><SPAN style="FONT-STYLE: italic">strXMLEditQueryData<SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN></SPAN>XML representation of the edit query data.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">The first three of these I can figure out just fine.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>The fourth, though, is pretty cryptic.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>What exactly does "XML representation of the edit query data" mean?<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>How am I supposed to write any sort of "representation" if I haven't been given an example of the format?</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">Well, if we get sneaky and look around a bit, we can find the format hiding in the HTML source.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Here's how.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">Let's do a search (in my case, I'm searching the portal for "test").<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>When we get the results, an Alert Me link will be on the left-hand pane.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Like a good sleuth, I'm going to "View Source" in IE.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>The HTML source for the Alert Me link looks like the following (FIND: Alert Me):</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1"><FONT color=#008000>&lt;a id="_ctl7:sch_mgmt_subs" class="" href="javascript:schOnSubscribeSearch();" mce_href="javascript:schOnSubscribeSearch();" accesskey="u" title="To be notified when new results are available or existing results change"&gt;Alert Me&lt;/a&gt;</FONT></P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">Alright.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Now we're getting somewhere.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>The link calls a JScript -- I know it <SPAN style="FONT-STYLE: italic">says</SPAN> javascript, but I'm sure they meant to say JScript, right? :) -- method schOnSubscribeSearch().<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Another hunt through the HTML source yields this function (FIND: schOnSubscribeSearch):</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; COLOR: black; FONT-SIZE: 8pt; mso-outline-level: 1"><FONT color=#008000>function schOnSubscribeSearch()</FONT></P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; COLOR: black; FONT-SIZE: 8pt; mso-outline-level: 1"><FONT color=#008000>{</FONT></P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; COLOR: black; FONT-SIZE: 8pt; mso-outline-level: 1"><FONT color=#008000>window.location.href = "javascript:spslcLBP\(&amp;#39;&amp;#39;,&amp;#39;&amp;#39;,&amp;#39;Search&amp;#39;,&amp;#39;&amp;#39;,&amp;#39;</FONT></P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; COLOR: black; FONT-SIZE: 8pt; mso-outline-level: 1"><FONT color=#008000>http:\\\/\\\/sharepointblank\\\/Search.aspx?k=test&amp;amp;s=All%2520sources&amp;#39;,&amp;#39;test&amp;#39;,&amp;#39;</FONT></P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; COLOR: black; FONT-SIZE: 8pt; mso-outline-level: 1"><FONT color=#008000>Search for </FONT><A href="file://&amp;quot;test/&amp;quot;&amp;#39;,ax0/(/)/" mce_href="file://&amp;quot;test/&amp;quot;&amp;#39;,ax0/(/)/"><FONT color=#008000>\\&amp;quot;test\\&amp;quot;&amp;#39;,ax0\(\)\</FONT></A><FONT color=#008000>);";</FONT></P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; COLOR: black; FONT-SIZE: 8pt; mso-outline-level: 1"><FONT color=#008000>}</FONT></P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">Sweeeet.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Now, that's some good looking stuff.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>If we get rid of some encoding, these parameters look something like:</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">spslcLBP("",</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">"",</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">"Search",</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">"",</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">"<A href="http://sharepointblank/Search.aspx?k=test&amp;s=All" mce_href="http://sharepointblank/Search.aspx?k=test&amp;s=All">http://sharepointblank/Search.aspx?k=test&amp;s=All</A> sources", </P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">"test", </P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">"Search for "test"", </P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">ax0());</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">Some more hunting, and I can find the spslcLBP function, in linkcreator.js.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Its parameter list looks like this:</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1"><FONT color=#008000>function spslcLBP(</FONT></P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2"><FONT color=#008000>oItem,</FONT></P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2"><FONT color=#008000>sUrl, </FONT></P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2"><FONT color=#008000>sAlertType,</FONT></P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2"><FONT color=#008000>sObjectDefinition,</FONT></P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2"><FONT color=#008000>sObjectUrl,</FONT></P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2"><FONT color=#008000>sObjectDisplay,</FONT></P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2"><FONT color=#008000>sSuggestedTitle,</FONT></P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2"><FONT color=#008000>sXmlParameters)</FONT></P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">A bit more looking into the HTML/JavaScript source, and I can determine that the last of these parameters is what I'm looking for -- in otherwords, if I can find what sXmlParameters looks like, I know what strXMLEditQueryData parameter should look like.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>In my spslcLBP that got rendered to the page, the sXmlParameters parameter is "ax0()".<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>This looks like another JScript function, so here I go searching through the HTML source of the page again (FIND: ax0()), and I find the culprit:</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1"><FONT color=#008000>&lt;SCRIPT DEFER&gt;function ax0() { return 'PFNlYXJjaE9wdGltaXphdGlvbj48</FONT></P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1"><FONT color=#008000>VGVybXM+dGVzdDwvVGVybXM+P</FONT><FONT color=#008000>FF1ZXJ5SW5mbz4gDQooKCJ1cm46c2N</FONT></P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1"><FONT color=#008000>oZW1hcy1taWNyb3NvZnQtY29tOnB1Ymxpc2hpbmc6</FONT><FONT color=#008000>SG9tZUJlc3RCZX</FONT><FONT color=#008000>RLZ</FONT></P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1"><FONT color=#008000>Xl3b3JkcyI9IHNvbWUgYXJyYXkgWyd0ZXN0J10gUkFOSyBCWSBDT0VSQ0l</FONT></P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1"><FONT color=#008000>PTihhYnNvbHV0ZSwgOTk5KSk</FONT><FONT color=#008000>NCk9SIChGUkVFVEVYVCgidXJuO</FONT><FONT color=#008000>nNjaGVtY</FONT></P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1"><FONT color=#008000>XMtbWljcm9zb2Z0LWNvbTpzaGFyZXBvaW50OnBvcnRhbDpwcm9</FONT><FONT color=#008000>maWxlOl</FONT></P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1"><FONT color=#008000>ByZWZlcnJlZE5hbWUiLCAndGVzdCcpIFJBTksgQlkgQ09FUkNJT04obXVsdGl</FONT></P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1"><FONT color=#008000>w</FONT><FONT color=#008000>bHksIDAuMDEpKQ0KT1</FONT><FONT color=#008000>IgRlJFRVRFWFQoI1dlaWdodGVkUHJvcHMsICd0ZX</FONT></P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1"><FONT color=#008000>N0JykgKQ0KIA0KICA8L1F1ZXJ5SW5mbz48L1NlYXJjaE9wd</FONT><FONT color=#008000>GltaXphdGlvbj4</FONT></P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1"><FONT color=#008000>=';}&lt;/SCRIPT&gt;</FONT></P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">Very nice.<SPAN style="mso-spacerun: yes">&nbsp; Base64-encoded data.&nbsp; </SPAN>Let's decode that bad boy and see what happens.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Once decoded from Base64, it looks like this [I've formatted with line breaks/indents]:</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">&lt;SearchOptimization&gt;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>&lt;Terms&gt;test&lt;/Terms&gt;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>&lt;QueryInfo&gt; </P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>(("urn:schemas-microsoft-com:publishing:HomeBestBetKeywords"= some array ['test'] RANK BY<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>COERCION(absolute, 999))</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">OR (FREETEXT("urn:schemas-microsoft-com:sharepoint:portal:profile:PreferredName", 'test') RANK BY COERCION(multiply, 0.01))</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">OR FREETEXT(#WeightedProps, 'test') )</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>&lt;/QueryInfo&gt;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">&lt;/SearchOptimization&gt;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">So, there's our format.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>As regards the GetAlertCreationLink() method of the Microsoft.SharePoint.Portal.Alerts.SearchAlertType class, the fourth argument, strXMLEditQueryData, should have the following format:</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">&lt;SearchOptimization&gt;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>&lt;Terms&gt;&lt;/Terms&gt;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>&lt;QueryInfo&gt;&lt;/QueryInfo&gt;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">&lt;/SearchOptimization&gt;</P>]]></content:encoded>
    </item>
    <item>
      <title>Finding Ghosts: Programmatically Determining Ghosted/Unghosted State</title>
      <link>https://docs.microsoft.com/archive/blogs/ryanrogers/finding-ghosts-programmatically-determining-ghostedunghosted-state</link>
      <pubDate>Tue, 22 Mar 2005 18:22:00 GMT</pubDate>
      <dc:creator><![CDATA[Ryan Rogers [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ryanrogers/2005/03/22/finding-ghosts-programmatically-determining-ghostedunghosted-state/</guid>
      <description><![CDATA[&nbsp; 
First, some terminology.&nbsp; The terms "ghosted" and "unghosted" get thrown around a lot...]]></description>
      <content:encoded><![CDATA[&nbsp; 
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">First, some terminology.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>The terms "ghosted" and "unghosted" get thrown around a lot when talking about SharePoint site definitions, and all too often, they are used incorrectly.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Here's the deal:</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">Ghosted:<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>a ghosted page is one that is read directly from the site definition on the filesystem.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">Unghosted:<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>an unghosted page is one that is read from the SharePoint database and *not* a physical file</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">So, how can we determine if a given page is either ghosted or unghosted?<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Luckily, there is a single property that will tell us:<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>"vti_hasdefaultcontent."<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>If this property exists on a file, it is ghosted (again, on the filesystem);<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>if the property does not exist, the file is being served from the database.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">Here's the code for a simple command-line utility that will take the URL to a given page and report whether it is ghosted or unghosted:</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">=====</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">using System;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">using Microsoft.SharePoint;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">namespace GhostCheck</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">{</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">public class Checker</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">{</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">[STAThread]</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">static void Main(string[] args)</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">{</P>
<P style="MARGIN: 0in 0in 0in 1.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 4">//if vti_hasdefaultocontent = true, it is ghosted;<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>if unghosted, the prop doesn't exist</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">if(args.Length == 0 || args[0].ToString().Equals("/?"))</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">{</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">Help();</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">}</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">else</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">{</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">string sURL = args[0].ToString();</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">bool hasError = false;</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">string sGhosted = CheckGhost(sURL, out hasError);</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">if(hasError)</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">{</P>
<P style="MARGIN: 0in 0in 0in 1.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 4">Console.WriteLine("\nError encountered: {0}", sGhosted);</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">}</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">else</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">{</P>
<P style="MARGIN: 0in 0in 0in 1.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 4">Console.WriteLine("\nThe page at {0} is {1}", sURL, sGhosted);</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">}</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">}</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">}</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">static<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>void Help()</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">{</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">Console.WriteLine("\nghostcheck &lt;URL&gt;");</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">Console.WriteLine("\nExample:<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>ghostcheck <A href="http://%3cmyserver%3e/sites/%3csite%3e/Lists/Contacts/NewForm.aspx" mce_href="http://%3cmyserver%3e/sites/%3csite%3e/Lists/Contacts/NewForm.aspx">http://&lt;myserver&gt;/sites/&lt;site&gt;/Lists/Contacts/NewForm.aspx</A>");</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">}</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">static string CheckGhost(string FileURL, out bool ErrorFlag)</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">{</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">ErrorFlag = false;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">SPSite oSite = null;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">SPWeb oWeb = null;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">SPFile oFile = null;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">try</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">{</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">oSite = new SPSite(FileURL);</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">}</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">catch(System.Exception exSite)</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">{</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">ErrorFlag = true;</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">return String.Format("Error getting Site: {0}", exSite.Message);</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">}</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">try</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">{</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">oWeb = oSite.OpenWeb();</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">}</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">catch(System.Exception exWeb)</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">{</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">ErrorFlag = true;</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">return String.Format("Error getting Web: {0}", exWeb.Message);</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">}</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">try</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">{</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">oFile = oWeb.GetFile(FileURL);</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">}</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">catch(System.Exception exFile)</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">{</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">ErrorFlag = true;</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">return String.Format("Error getting File: {0}", exFile.Message);</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">}</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">System.Collections.Hashtable oHash = oFile.Properties;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">if(oHash.ContainsKey("vti_hasdefaultcontent"))</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">{</P>
<P style="MARGIN: 0in 0in 0in 1.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 4">return "ghosted (on file system)";</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">}</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">else</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">{</P>
<P style="MARGIN: 0in 0in 0in 1.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 4">return "unghosted (in database)";</P>
<P style="MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 3">}</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">}</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">}</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">}</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">=====</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">This utility uses the SharePoint object model, and so MUST BE RUN ON THE SERVER, not from a client.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">Usage:</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">ghostcheck.exe &lt;URL&gt;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1">Example:</P>
<P style="MARGIN: 0in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; mso-outline-level: 2">ghostcheck.exe <A href="http://myserver/sites/mysite/Lists/Contacts/NewForm.aspx" mce_href="http://myserver/sites/mysite/Lists/Contacts/NewForm.aspx">http://myserver/sites/mysite/Lists/Contacts/NewForm.aspx</A></P>]]></content:encoded>
    </item>
    <item>
      <title>Drawing the Curtain:  Removing Access to the Site Settings Page for non-Administrative Users</title>
      <link>https://docs.microsoft.com/archive/blogs/ryanrogers/drawing-the-curtain-removing-access-to-the-site-settings-page-for-non-administrative-users</link>
      <pubDate>Wed, 23 Feb 2005 14:54:00 GMT</pubDate>
      <dc:creator><![CDATA[Ryan Rogers [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ryanrogers/2005/02/23/drawing-the-curtain-removing-access-to-the-site-settings-page-for-non-administrative-users/</guid>
      <description><![CDATA[&nbsp; 
NOTE:&nbsp; In this article, I discuss making some changes to SharePoint which are...]]></description>
      <content:encoded><![CDATA[&nbsp; 
<P style="FONT-STYLE: italic; MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">NOTE:<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>In this article, I discuss making some changes to SharePoint which are unsupported by Microsoft.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>As an employee within the Support realm, I want to stress that the CheckPermissions() solution below is currently unsupported by Microsoft -- if you make the change, you are on your own.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>:)<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>That said, I have gone ahead and discussed some of the ramifications of making the change, because I think that the solution is a good one despite its being unsupported.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>In short -- you've been warned.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">You might have noticed that authenticated users granted Reader access to a SharePoint site also have access to the Site Settings page:<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>_layouts/&lt;LCID&gt;/settings.aspx.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Although these users will typically have no rights to access any of the pages linked therein, it might be desirable to remove access to the settings.aspx page altogether, so that non-Administrative users don't even have the option to see what can be done from an administrative perspective.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Honestly, I'm really not sure why this page is able to be viewed by non-Administrative users to begin with, but that's irrelevant;<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>it is viewable, and I want to change that.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">I have two options, one supported and one unsupported</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">1)<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Somewhat complicated, but supported:<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>write a wildcard-mapped ISAPI extension</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">2)<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Simple, but strictly not supported:<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>drop a CheckPermissions() call onto the settings.aspx page</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">I've covered both of these options in more detail below:</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">*****</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; FONT-WEIGHT: bold; mso-outline-level: 1">ISAPI Extension</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">Although writing an ISAPI extension isn't a particularly simple task, and requires knowledge of C++ programming, etc., it is a possible (and supported) solution.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Essentially, I would need to create an wildcard-mapped ISAPI extension that examined each request.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>I would start by checking the requested URL by looking in the VTI_SCRIPT_NAME server variable.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>If that request was for a _layouts page (settings.aspx in particular), my ISAPI extension could check the authentication type and/or authentication user from the server variables (AUTH_TYPE, and AUTH_USER).<SPAN style="mso-spacerun: yes">&nbsp; </SPAN></P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">If, for example, the AUTH_USER server variable were blank, the ISAPI extension could redirect by posting a 302 Redirect to some other URL -- including, for example, a custom error page somewhere.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">The IIS SDK includes ISAPI extension samples, including a wildcard-mapped ISAPI extension sample.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Here's a link to the Platform SDK Update site, where you can obtain any of the various platform SDK modules:</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1"><A href="http://www.microsoft.com/msdownload/platformsdk/sdkupdate/" mce_href="http://www.microsoft.com/msdownload/platformsdk/sdkupdate/">http://www.microsoft.com/msdownload/platformsdk/sdkupdate/</A></P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">I would start with the WildcardMap sample provided in the SDK (...\Microsoft SDK\Samples\web\iis\ISAPI_6.0\WildCardMap).<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>This sample is specifically designed to capture *every* request.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>To use this with IIS, I'll need to register the built ISAPI extension within IIS.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN></P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">NOTE: With Windows Server 2003 and with SharePoint Portal Server (or Windows SharePoint Services), there are some additional steps required to get the ISAPI extension functioning, which I cover below.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">Once built, I can simply open up the IIS management console, right-click the web site I want to register the ISAPI with to get the web site properties, and choose the "Home Directory" (or "Virtual Directory" if this is a virtual directory rather than a web site) tab.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN></P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">Click the "Configuration..." button to open the "Application Configuration" dialog.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Under the "Wildcard application maps" section, choose "Insert..." and enter the path to my built DLL (or choose "Browse..." to find it).<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>IMPORTANT:<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>to use an ISAPI extension with Sharepoint, I must UN-check the "Verify that file exists" checkbox.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">Apply all of those changes to the web site or virtual directory.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">Next, in IIS management console, I select "Web Server Extensions."<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>This will bring up a list of the allowed and prohibited extensions.&nbsp; I'll need to click on "Add a new Web service extension..." give the Extension a name, provide a link to the built DLL, and set the status to "Allowed."</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">At that point, my ISAPI extension should be ready to work.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; FONT-WEIGHT: bold; mso-outline-level: 1">CheckPermissions()</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">There *is* an alternative workaround, which -- unfortunately -- is not supported by Microsoft.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>If I open one of the various administrative ASPX pages in Visual Studio.NET (or Notepad, for that matter) and view the code, I can see that there is an explicit check for role-based permissions.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>For example, in User.ASPX, which is located at x:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\Template\Layouts\1033\user.aspx, the line of code which checks permissions looks like this:</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">=====</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">&lt;% spWeb.Permissions.CheckPermissions(SPRights.ManageRoles); %&gt;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">=====</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">This line checks to see if the current user has the ManageRoles right.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>If so, the user is allowed to view the page;<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>if not, the user is prompted for authentication.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>In contrast, the Settings.aspx page -- the first that a user sees after clicking on "Site Settings" in a WSS site -- contains no such permissions check.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">The SPRights enumeration is covered in the MSDN Library at the location below:</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">=====</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1"><A href="http://msdn.microsoft.com/library/en-us/spptsdk/html/tsenSPRights_SV01013656.asp?frame=true" mce_href="http://msdn.microsoft.com/library/en-us/spptsdk/html/tsenSPRights_SV01013656.asp?frame=true">SPRights Enumeration</A></P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">=====</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">This enumeration contains various rights that can be assigned to a user.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>For example, the ViewPages right allows a user to view pages within a WSS Site.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>It would be possible -- though, again, not supported -- to add a line of code like the one above to the various administrative settings pages that you wanted to restrict to Administrative users only.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>For instance, if I wanted to restrict access to the Settings.aspx page only to users who have the ManageWeb right, I could include the following line of code in settings.aspx (existing/surrounding code included for reference, new code in bold):</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">=====</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">SPWeb spWeb = SPControl.GetContextWeb(Context); %&gt;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; FONT-WEIGHT: bold; mso-outline-level: 1">&lt;% spWeb.Permissions.CheckPermissions(SPRights.ManageWeb); %&gt;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">&lt;HEAD&gt; </P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">=====</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">With this code in place, when a user attempts to go to the settings.aspx page, Sharepoint will check to see if they have the ManageWeb right;<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>if so, they can view the page -- if not, they'll be denied access and prompted for credentials.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">The big caveat, as I've mentioned, is that this solution is not supported by Microsoft.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>We do not support making any direct modifications to the code used in any of the pages in the LAYOUTS directory.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>What this means is that if you were to apply this change and later were to run into any problems on your server, Microsoft PSS would require that the change be rolled back before any assistance could be given.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Additionally, Microsoft has reserved the right to overwrite any of the default (out-of-the-box) files located in the LAYOUTS directory in any future service packs or updates.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Such an overwrite would wipe out changes, so I would need to be aware of the changes that I've made so that I could re-implement in such a case.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">*****</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="FONT-STYLE: italic; MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">There is one scenario in which this isn't an issue:<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Anonymous access over the internet.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>If I have setup a SharePoint site to allow anonymous authentication, and a user browses to my site, they can view pages such as default.aspx just fine.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>As soon as they attempt to view settings.aspx, though, they will be prompted.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Because the user is not on my domain, Windows Integrated authentication cannot negotiate authentication to settings.aspx, and the user will be prompted. </P>]]></content:encoded>
    </item>
    <item>
      <title>What's on the Menu? - How to Remove Items from a Document Library Drop-down Menu</title>
      <link>https://docs.microsoft.com/archive/blogs/ryanrogers/whats-on-the-menu-how-to-remove-items-from-a-document-library-drop-down-menu</link>
      <pubDate>Fri, 11 Feb 2005 01:19:00 GMT</pubDate>
      <dc:creator><![CDATA[Ryan Rogers [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ryanrogers/2005/02/11/whats-on-the-menu-how-to-remove-items-from-a-document-library-drop-down-menu/</guid>
      <description><![CDATA[&nbsp;
The SDK includes documentation explaining how to create a custom Jscript file that can...]]></description>
      <content:encoded><![CDATA[<P><FONT size=2 face=Tahoma><FONT size=3 face="Times New Roman"></FONT>&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">The SDK includes documentation explaining how to create a custom Jscript file that can override the default functions that create items in the cute little drop-down menu associated with list items.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>For example, the drop-down below is for a PowerPoint presentation in a WSS document library:</P></FONT>
<P><FONT size=2 face=Tahoma><IMG src="http://ryanrogers.sts.winisp.net/blog/menu_before.GIF" width=257 height=249 mce_src="http://ryanrogers.sts.winisp.net/blog/menu_before.GIF"></P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">The SDK describes how to override a default method (AddCheckinCheckoutMenuItem) in order to create a new Check Out &amp; Save item on the menu.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1"><A href="http://msdn.microsoft.com/library/en-us/spptsdk/html/tsptAddingContextMenu_SV01068564.asp?frame=true" mce_href="http://msdn.microsoft.com/library/en-us/spptsdk/html/tsptAddingContextMenu_SV01068564.asp?frame=true">Customizing the Shortcut Menu for List Items</A></P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">However, what if we want to *remove* items from the menu?<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>For example, let's say that we want to remove the "Edit in Microsoft Office…" link from the menu so that our users are not presented with that option;<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>how would we go about it?<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>How would we override default methods in order to remove any of the other items on the menu (Alert Me, Discuss, etc.)?</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">To begin, we have to look at the function in ows.js that creates the document library menu items:<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>AddDocLibMenuItems.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Within this function, you'll see a bunch of calls to the CAMOpt function, which is also defined in ows.js.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>CAMOpt is the function responsible for actually writing each menu item;<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>if we remove the call to CAMOpt for a specific menu item, we effectively remove that menu item!</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">For example, the AddDoclibMenuItems function contains the following code, which writes the "Edit in [Application]" menu item:</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">setDocType();</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">if (currentItemAppName != "" &amp;&amp; currentItemOpenControl != "")</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">{</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 2">strDisplayText = StBuildParam(L_EditIn_Text, currentItemAppName);</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 2">strAction = "editDocumentWithProgID2('" + currentItemFileUrl + "', '" + currentItemProgId + "', '" + currentItemOpenControl + "')";</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 2">strImagePath = ctx.imagesPath + currentItemIcon;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 2">CAMOpt(m, strDisplayText, strAction, strImagePath);</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">}</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">If we comment out the call to CAMOpt…</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 2">//CAMOpt(m, strDisplayText, strAction, strImagePath);</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">...the "Edit in [Application]" item/option will no longer show up for menus on document library items.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Below is a screenshot of the menu for a PowerPoint presentation on a WSS site where a custom ows.js file has been applied (following the instructions in Customizing the Shortcut Menu for List Items) that *only* includes an overridden AddDoclibMenuItems function with the specific CAMOpt call above commented out:</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; mso-outline-level: 1"><IMG src="http://ryanrogers.sts.winisp.net/blog/menu_after.gif" width=257 height=230 mce_src="http://ryanrogers.sts.winisp.net/blog/menu_after.gif"></P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">So, how can you figure out which CAMOpt call is adding which menu item?<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Simple.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>:)<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>The second parameter passed is the display text (strDisplayText);<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>all of the calls to CAMOpt in AddDocLibMenuItems use a string constant for this parameter.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>The string constants are defined in ows.js, and I've reprinted them below:</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">=====</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_Edit_Text= "Edit";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_ViewItem_Text= "View Item";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_EditItem_Text= "Edit Item";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_EditSeriesItem_Text = "Edit Series";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_DeleteItem_Text= "Delete Item";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_DeleteDocItem_Text<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>= "Delete";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_ViewProperties_Text = "View Properties";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_EditProperties_Text = "Edit Properties";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_Discuss_Text= "Discuss";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_Subscribe_Text= "Alert Me";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_Review_Text= "Send for Review";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_EditIn_Text= "Edit in ^1"; </P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_Checkin_Text= "Check In";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_Checkout_Text= "Check Out";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_CreateDWS_Text= "Create Document Workspace";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_PublishBack_Text= "Publish to Source Location";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_Versions_Text= "Version History";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_Reply_Text= "Reply";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_ExportContact_Text<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>= "Export Contact";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_ExportEvent_Text= "Export Event";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_Reschedule_Text= "Rescheduling Options";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_Move_Text= "Move";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_Keep_Text= "Keep";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_Delete_Text= "Delete";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_Open_Text= "Open";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_SiteSettings_Text<SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>= "Change Site Settings";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_ManageUsers_Text= "Manage Users";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_DeleteSite_Text= "Delete Site";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_SiteStorage_Text= "Manage Site Storage";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_Sharing_Text= "Sharing";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_Settings_Text= "Settings";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_Remove_Text= "Remove from this list";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_ModerateItem_Text<SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>= "Approve/reject";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_DownloadOriginal_Text = "Download Picture";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_EditVersion_Text= "Edit";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_ViewVersion_Text= "View";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_RestoreVersion_Text = "Restore";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_DeleteVersion_Text<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>= "Delete";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_EditInOIS_Text= "Edit Picture";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_AddToMyLinks_Text<SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>= "Add to My Links";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">var L_AddToCategory_Text<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>= "Submit to Portal Area";</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">=====</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">So, you can simply find the display text of the item you want to remove [from ALL sites], find its string constant (e.g. L_Subscribe_Text for "Alert Me"), find the corresponding CAMOpt call by searching for the string constant name in your AddDocLibMenuItems function -- in your custom .js file -- and comment it out.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">Ta-da.</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1" mce_keep="true">&nbsp;</P>
<P style="MARGIN: 0in; FONT-FAMILY: Tahoma; FONT-SIZE: 8pt; mso-outline-level: 1">NOTE of course, that making changes directly to ows.js is not supported, and can potentially cause other unexpected problems.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Additionally, a custom .js file should only be applied to a custom site definition as described in the article above.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>If you follow the rules, though, you can make a wide variety of customizations to the way that items are displayed in SharePoint sites!</P></FONT>]]></content:encoded>
    </item>
  </channel>
</rss>