If like me you’re wondering what exactly does SPSecurity.RunWithElevatedPrivileges
, this is what I understand of it :
SPSecurity.RunWithElevatedPrivileges( () => {
using( var newSite = new SPSite( site.Url ) ) {
// your stuff
}
});
Is equivalent to :
using( var newSite = new SPSite( site.Url, site.SystemAccount.Token ) ) {
// your stuff
}
So if this is just to open an elevated privilege SPSite
, it will be equivalent. But if you do some more complex things,
as soon as you load a new SPSite
it will open it with the original UserToken
. And you lose…