Is there a way to detect if my code is running inside SPSecurity.RunWithElevatedPrivileges?
class Foo
{
public static void Bar()
{
if (CODE_RUNS_ELEVATED)
{
Debug.WriteLine("You are elevated");
}
else
{
Debug.WriteLine("You are not elevated");
}
}
}
SPSecurity.RunWithElevatedPrivileges(() => Foo.Bar()); // Prints: You are elevated
Foo.Bar(); // Prints: You are not elevated
My problem is how to resolve CODE_RUNS_ELEVATED
.