Showing posts with label Best Practices. Show all posts
Showing posts with label Best Practices. Show all posts
Monday, September 24, 2012
Wednesday, June 13, 2012
Overview of using fine-grained permissions
Item Level Permissions and Performance:
http://anilmukka.wordpress.com/2011/05/05/overview-of-using-fine-grained-permissions/
http://e-junkie-chronicles.blogspot.de/2011/03/sharepoint-2010-performance-with-item.html
http://e-junkie-chronicles.blogspot.de/2011/03/sharepoint-2010-performance-with-item_23.html
http://anilmukka.wordpress.com/2011/05/05/overview-of-using-fine-grained-permissions/
http://e-junkie-chronicles.blogspot.de/2011/03/sharepoint-2010-performance-with-item.html
http://e-junkie-chronicles.blogspot.de/2011/03/sharepoint-2010-performance-with-item_23.html
Tuesday, June 12, 2012
Friday, May 4, 2012
Thursday, December 22, 2011
SPSecurity.RunWithElevatedPrivileges
The ideal way to Elevate Privileges:
(Code written on the run - Check for build errors)
Guid SiteID = SpWeb.Current.Site.ID;
Guid WebID = SPWeb.Current.Web.ID;
SpSecurity.RunWithElevatedPrivileges(delegate(){
using (SPSite oSite = new SPSite(sSiteID))
{
});
One thing to be kept in mind while implementing such logic is that any SP Object with is created outside of the RWEP belongs to that particular context and when that SP Object is sent inside the RWEP, the elevation is lost.
For Example, if I need to use a list within the RWEP, then I should follow these:
DoSomethingWithTheList(SPList tempList)
{
Guid SiteID = SpWeb.Current.Site.ID;
Guid WebID = SPWeb.Current.Web.ID;
string sListName = tempList.Title;
SpSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite oSite = new SPSite(sSiteID))
{
});
}
(Code written on the run - Check for build errors)
Guid SiteID = SpWeb.Current.Site.ID;
Guid WebID = SPWeb.Current.Web.ID;
SpSecurity.RunWithElevatedPrivileges(delegate(){
using (SPSite oSite = new SPSite(sSiteID))
{
using (SPWeb oWeb = oSite.OpenWeb(WebID))
{
//Logic
}
}});
One thing to be kept in mind while implementing such logic is that any SP Object with is created outside of the RWEP belongs to that particular context and when that SP Object is sent inside the RWEP, the elevation is lost.
For Example, if I need to use a list within the RWEP, then I should follow these:
DoSomethingWithTheList(SPList tempList)
{
Guid SiteID = SpWeb.Current.Site.ID;
Guid WebID = SPWeb.Current.Web.ID;
string sListName = tempList.Title;
SpSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite oSite = new SPSite(sSiteID))
{
using (SPWeb oWeb = oSite.OpenWeb(WebID))
{
SPList oList = oWeb.Lists.TryGetList(sListName);
SPList oList = oWeb.Lists.TryGetList(sListName);
//Logic
}
}});
}
Labels:
Best Practices,
Elevated Privileges,
Impersonation,
SPSecurity
Saturday, October 8, 2011
Best Practices: Using Disposable Windows SharePoint Services Objects
Subscribe to:
Posts (Atom)