Search This Blog

Monday, November 21, 2011

Code to implement Elevated Priviledeges without using RunWithElevatedPriviledege

Hi friends,


While reading, I came through some nice information where we can implement their own way of doing Elevated Priviledege without using RunWithElevatedPriviledege.


Please have a look:

var userAccount = SPContext.Current.Web.AllUsers[@"SHAREPOINT\SYSTEM"];
var userToken = userAccount.UserToken;
using (var site = new SPSite(SPContext.Current.Web.Url, userToken))
{
// This code runs under the security context of the SHAREPOINT\system
using(var elevatedWeb = site.OpenWeb())
{
// Perform actions as SYSTEM
}
}


For more reference : http://msdn.microsoft.com/en-us/library/bb466220%28v=office.12%29.aspx


Many Thanks
Prabhat

No comments:

Post a Comment