<?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>Florent Clairambault &#187; SPWeb</title>
	<atom:link href="http://florent.clairambault.fr/tag/spweb/feed" rel="self" type="application/rss+xml" />
	<link>http://florent.clairambault.fr</link>
	<description></description>
	<lastBuildDate>Thu, 09 Sep 2010 23:45:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1-alpha</generator>
		<item>
		<title>SPSecurity.RunWithElevatedPrivileges</title>
		<link>http://florent.clairambault.fr/spsecurity-runwithelevatedprivileges?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=spsecurity-runwithelevatedprivileges</link>
		<comments>http://florent.clairambault.fr/spsecurity-runwithelevatedprivileges#comments</comments>
		<pubDate>Mon, 22 Feb 2010 20:00:56 +0000</pubDate>
		<dc:creator>Florent Clairambault</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[C# .Net]]></category>
		<category><![CDATA[Sharepoint]]></category>
		<category><![CDATA[SPSite]]></category>
		<category><![CDATA[SPWeb]]></category>

		<guid isPermaLink="false">http://florent.clairambault.fr/?p=2303</guid>
		<description><![CDATA[If like me you&#8217;re wondering what exactly does SPSecurity.RunWithElevatedPrivileges, this is what I understand of it : 1 2 3 4 5 SPSecurity.RunWithElevatedPrivileges&#40; &#40;&#41; =&#62; &#123; using&#40; var newSite = new SPSite&#40; site.Url &#41; &#41; &#123; // your stuff &#125; &#125;&#41;; Is equivalent to : 1 2 3 using&#40; var newSite = new SPSite&#40; site.Url, [...]]]></description>
			<content:encoded><![CDATA[<p>If like me you&#8217;re wondering what exactly does SPSecurity.RunWithElevatedPrivileges, this is what I understand of it :</p>

<div class="wp_codebox"><table><tr id="p23033"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p2303code3"><pre class="csharp" style="font-family:monospace;">SPSecurity<span style="color: #008000;">.</span><span style="color: #0000FF;">RunWithElevatedPrivileges</span><span style="color: #008000;">&#40;</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">=&gt;</span> <span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">using</span><span style="color: #008000;">&#40;</span> var newSite <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> SPSite<span style="color: #008000;">&#40;</span> site<span style="color: #008000;">.</span><span style="color: #0000FF;">Url</span> <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
        <span style="color: #008080; font-style: italic;">// your stuff</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

<p>Is equivalent to :</p>

<div class="wp_codebox"><table><tr id="p23034"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p2303code4"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">using</span><span style="color: #008000;">&#40;</span> var newSite <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> SPSite<span style="color: #008000;">&#40;</span> site<span style="color: #008000;">.</span><span style="color: #0000FF;">Url</span>, site<span style="color: #008000;">.</span><span style="color: #0000FF;">SystemAccount</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Token</span> <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    <span style="color: #008080; font-style: italic;">// your stuff</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>So if this is just to open an elevated privilege SPSite, it will be equivalent. But if you do some more complex things, as soon as you load a new SPSite it will open it with the original UserToken. And you lose&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://florent.clairambault.fr/spsecurity-runwithelevatedprivileges/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
