Elevation of privilege, a feature that was added in Windows SharePoint Services 3.0, enables you to programmatically perform actions in code by using an increased level of privilege. The SPSecurity.RunWithElevatedPrivileges method enables you to supply a delegate that runs a subset of code in the context of an account with higher privileges than the current user.
A standard use of RunWithElevatedPrivileges is:
A standard use of RunWithElevatedPrivileges is:
SPSecurity.RunWithElevatedPrivileges(delegate() { // Do things by assuming the permission of the "system account". });
Frequently, to perform actions in SharePoint, you must get a new SPSite object to effect the changes. For example:
SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPSite site = new SPSite(web.Site.ID)) { // Do things by assuming the permission of the "system account". } });
Although elevation of privilege provides a powerful technique for managing security, it should be used with care. You should not expose direct, uncontrolled mechanisms for people with low privileges to circumvent the permissions granted to them.
No comments:
Post a Comment
Thank you for Commenting Will reply soon ......