Hi,
Here I am listing some of the things that you have to take care when you are working with SPSecurity.RunWithElevatedPrivilages.
1) Don't get the instances of SPSite and SPWeb from the context variables.
Eg: If you have RunWithElevatedPrivilages in Event Handlers. Don't get the instances of sitecollection and site from properties varibales directly.
Don't Use
i.e SPSite site=properties.site;
SPWeb web= properties.openweb();
Use
SPSite site = new SPSite(properties.SiteId)
SPWeb web = site.OpenWeb(properties.RelativeWebUrl)
Because the first code returns the instances with the current user prevelages. so, eventhough you are working with elevated privilages you will get access problems with those instances.
No comments:
Post a Comment