title: How to use WindowsIdentity.RunImpersonated(handle, action);
body: <p>We are trying to use RunImpersonated(handle, action); to be able to perform a REST call from a webserver but we have a hard time doing so. Project i ASP.NET Core 2.0 MVC.</p>
  <p>We have the following general method made to establish a imp. context on behalf of the logged in wnd. user:</p>
  <pre><code>var user = WindowsIdentity.GetCurrent();
  
  IntPtr token = user.Token;
  SafeAccessTokenHandle handle = new SafeAccessTokenHandle(token);
  
  WindowsIdentity.RunImpersonated(handle, action);
  </code></pre>
  <p>and basically in the action we make our REST call.</p>
  <p>Thing is that we CAN run through without any problems running locally on our dev machines but we can't do the same on the remote webserver. Hence: impersonation.</p>
  <p>Is our approach above for the imp. part right since we can't actually se if we promote any user-credentials?</p>
  <p>We have tried different techniques in the REST-GET impl. as well without the above. On the other hand the above call are made closer to our controller and on REST impl. not having any specifics for imp. itself.</p>