Does SPSecurity.RunWithElevated Privileges provide anything in the console application?

From what I learned from the reflector, RunWithElevatedPriveleges simply returns the current thread identity to the base (without impersonation) identifier. This makes sense in the case of code running inside the WSS application pool, since the basic service account is the superuser. Does this have an effect when working in an external (console or service) application when there is no impersonation? I suppose not, but I would like to know for sure. I saw different opinions about this from googling.

+3
source share
3 answers

Normally Runwithelevatedprivileges will get your code running as an application pool identifier, but it does not work from the console. What we did in this case is either using runas , or set the identity of the scheduled task for the same account as the application pool identifier.

+3
source

I think that if you ran the executable file under one account and then change its credentials with a code (for example, SP). Otherwise, it cannot raise to the permission that it did not have at startup without any way of creating the Credentials object.

+3
source

RunWithElevatedPriveleges , HTTPContext null. HTTPContext null.

0

Source: https://habr.com/ru/post/1697386/


All Articles