It is very importent to understand why and when to use SPSecurity.RunwithElevatedPrivilages.When we want to retrive or update the data where a normal user don't have permission,there we use this code segment. How this exactly works is like SPSecurity.RunWithElevatedPrivileges runs current process under application pool identity and it allows users to add/update item in list,library or site.
Example
Example
SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPSite site = new SPSite(web.Site.ID)) { // site will be based on the rights for the system account } });
For more details click here
No comments:
Post a Comment