AspNetCoreDiagnosticScenarios icon indicating copy to clipboard operation
AspNetCoreDiagnosticScenarios copied to clipboard

WindowsIdentity.RunImpersonated errors

Open mriehm opened this issue 2 years ago • 1 comments

Reading the WindowsIdentity.RunImpersonated examples in the AsyncGuidance, there appear to be two errors:

  1. Each of the delegates are defined as taking a context parameter. However, RunImpersonated does not take any delegate with parameters. It only takes Action or Func<T> (Func<Task> or Func<Task<T>> for RunImpersonatedAsync), so why is this context parameter in the examples?
  2. The first BAD example appears to be incorrect. It states: "This example tries to execute the query asynchronously, and then wait for it outside of the call to RunImpersonated. This will throw because the query might be executing outside of the impersonation context." However, that example code doesn't actually have any functional problem. In fact, it is semantically equivalent to the first GOOD example, which we can confirm by seeing that the supposedly BAD example matches the runtime implementation of the RunImpersonated<T> method that is used in the first GOOD example.

mriehm avatar Jan 24 '22 05:01 mriehm

Thanks, send a PR please

davidfowl avatar Apr 11 '22 04:04 davidfowl