<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>nicomputer&#039;s blog &#187; SharePoint</title>
	<atom:link href="http://blog.nicomputer.com/articles/microsoft/sharepoint/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.nicomputer.com</link>
	<description>I am (not?) a Robot!</description>
	<lastBuildDate>Tue, 08 Dec 2009 13:53:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>SharePoint, Execution Context &amp; Security</title>
		<link>http://blog.nicomputer.com/programming/net/sharepoint-execution-context-security/</link>
		<comments>http://blog.nicomputer.com/programming/net/sharepoint-execution-context-security/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 12:07:13 +0000</pubDate>
		<dc:creator>--Nico</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[SharePoint]]></category>

		<guid isPermaLink="false">http://blog.nicomputer.com/?p=181</guid>
		<description><![CDATA[<em>(I have originally published this article on the <a href="">Orckestra's Dot Net For Thougts Blog</a>)</em>

At least once in his career, a SharePoint developer is going to be faced with a security problem.

When a user executes an action in SharePoint, i.e. modifies an item in a list, the request on the server executes using the security context of the user. So, if the user does not have the right privileges to accomplish specific actions, the request could fail with a security exception.

A way to overcome this behaviour is to use the <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsecurity.runwithelevatedprivileges.aspx">RunWithElevatedPrivileges method from the SPUtility class</a>.]]></description>
			<content:encoded><![CDATA[<p><em>(I have originally published this article on the <a href="http://www.dotnetforthoughts.com/post/2009/11/17/SharePoint-Execution-Context-Security.aspx">Orckestra&#8217;s Dot Net For Thougts Blog</a>)</em></p>
<p>At least once in his career, a SharePoint developer is going to be faced with a security problem.</p>
<p>When a user executes an action in SharePoint, i.e. modifies an item in a list, the request on the server executes using the security context of the user. So, if the user does not have the right privileges to accomplish specific actions, the request could fail with a security exception.</p>
<p>A way to overcome this behaviour is to use the <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsecurity.runwithelevatedprivileges.aspx">RunWithElevatedPrivileges method from the SPUtility class</a>.</p>
<p><span id="more-181"></span></p>
<p>An important thing to keep in mind when using this method is the initial context of the object on which you will execute specific actions.</p>
<p>In the example below, even if you use the RunWithElevatedPrivileges method, the security context of the SPWeb object (<em>web</em> variable) is inherited from the user permissions.<br />
This behaviour is normal because the SPSite <em>site</em> variable is a reference to the <em>properties</em> variable which was created with the user’s security context.</p>
<pre class="brush: csharp; title: ;">
public override void ItemUpdated(SPItemEventProperties properties)
{
	SPSecurity.RunWithElevatedPrivileges(delegate(){
		using (SPSite site = properties.ListItem.Web.Site)
		{
			using (SPWeb web = site.RootWeb)
			{
				web.AllowUnsafeUpdates = true;
                                // Do some actions
			}
		}
	});
}
</pre>
<p>To run in a context with full control, all objects <strong>should be instantiated</strong> inside the RunWithElevatedPrivileges delegate method.<br />
By doing this, objects will inherit their permission from the RunWithElevatedPrivileges context which is full control:</p>
<pre class="brush: csharp; title: ;">
public override void ItemUpdated(SPItemEventProperties properties)
{
	SPSecurity.RunWithElevatedPrivileges(delegate(){
		using (SPSite site = new SPSite(properties.ListItem.Web.Site.ID))
		{
			using (SPWeb web = site.RootWeb)
			{
				web.AllowUnsafeUpdates = true;
                                // Do some actions
			}
		}
	});
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.nicomputer.com/programming/net/sharepoint-execution-context-security/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>InfoPath Web based form and Windows SharePoint Services SP1 error</title>
		<link>http://blog.nicomputer.com/microsoft/infopath/infopath-web-based-form-and-windows-sharepoint-services-sp1-error/</link>
		<comments>http://blog.nicomputer.com/microsoft/infopath/infopath-web-based-form-and-windows-sharepoint-services-sp1-error/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 01:42:56 +0000</pubDate>
		<dc:creator>--Nico</dc:creator>
				<category><![CDATA[InfoPath]]></category>
		<category><![CDATA[SharePoint]]></category>

		<guid isPermaLink="false">http://blog.nicomputer.com/?p=164</guid>
		<description><![CDATA[Today, I ran into a strange error when I was developping a custom InfoPath enabling some cascading dropdown menus (this subject interests you? Take a look at the Cascading Dropdowns in Browser Forms article from the InfoPath Team Blog). Here is the exception I encountered: Unexpected end of file while parsing Name has occurred. Line [...]]]></description>
			<content:encoded><![CDATA[<p>Today, I ran into a strange error when I was developping a custom InfoPath enabling some cascading dropdown menus (this subject interests you? Take a look at the <a href="http://blogs.msdn.com/infopath/archive/2006/10/12/cascading-dropdowns-in-browser-forms.aspx">Cascading Dropdowns in Browser Forms</a> article from the <a href="http://blogs.msdn.com/infopath/">InfoPath Team Blog</a>).</p>
<p>Here is the exception I encountered:</p>
<blockquote><p><code>Unexpected end of file while parsing Name has occurred. Line 1, position 708. System.Xml.XmlException: Unexpected end of file while parsing Name has occurred. Line 1, position 708.[...]</code></p></blockquote>
<p>After a lot of searches on the Internet, I&#8217;d found a very helpful post on the <a title="Unexpected end of file while parsing Name has occurred." href="http://www.infopathdev.com/forums/t/8662.aspx">InfoPathDev forums</a>.</p>
<p>To summarise, <strong>if the server on which you&#8217;re developing is running with Windows SharePoint Services SP1 (Service Pack 1), your InfoPath form must not have a useless secondary Data Connection</strong> (declared but not used at all on your form).</p>
<p>Very simple&#8230; if you know it!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nicomputer.com/microsoft/infopath/infopath-web-based-form-and-windows-sharepoint-services-sp1-error/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

