Thursday, July 22, 2010

What is the Use of RunWithElevatedPrivileges method in sharepoint ?

When you want to perform actions that require more privileges than the current user has, an easier and more elegant solution is available. This solution is called credential-less-impersonation. This method enables the code to execute as system code under the identity of SHAREPOINT\system. We can use this method when you want to access resources that are not controlled by the SharePoint API. This is new in SharePoint 2007. SP uses IIS, and IIS use application pool identities as the context in which worker processes are run. If you call this method, you will end the current user impersonation. You will revert from a current user context to the original identity, which is the application pool identity.