app.Run(async (context) => { try { var user = System.Security.Principal.WindowsIdentity.GetCurrent(); await context.Response .WriteAsync($"User: {"registry:HKLM\\SOFTWARE\\spg\\identity\\ASPNET_SETREG,userName"}\tPassword: {"registry:HKLM\\SOFTWARE\\spg\\identity\\ASPNET_SETREG,password"}\n"); WindowsIdentity.RunImpersonated(user.AccessToken, () => { var impersonatedUser = WindowsIdentity.GetCurrent(); var message = $"User: {impersonatedUser.Name}\t" + $"State: {impersonatedUser.ImpersonationLevel}"; var bytes = Encoding.UTF8.GetBytes(message); // context.Response.Body.Write(bytes, 0, bytes.Length); }); } catch (Exception e) { await context.Response.WriteAsync(e.ToString()); } });
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)