ASP.NET(4.8)与应用程序池标识-如何模拟当前用户在一个单一的HTTP客户端请求,而不是应用程序池标识

igsr9ssn  于 2022-12-14  发布在  .NET
关注(0)|答案(1)|浏览(109)

I have an ASP.NET Framework 4.8 app that runs in IIS under the App Pool Identity, but I have several HTTP Client requests in the app to services on the same machine that need to execute as the current user instead of the App Pool Identity. What's the best way to do this?
I've tried the impersonation solutions I've found on StackOverflow, but those didn't work, and the HTTP requests still ran as the App Pool Identity.

vmdwslir

vmdwslir1#

下面是一个如何将用户“abc”设置为模拟身份验证的示例。
这是一个框架4.8的Web窗体应用程序,默认情况下是由visual studio生成的,我添加了“Response.Write(System.Security.Principal.WindowsIdentity.GetCurrent().Name);“以显示当前正在使用的用户。x1c 0d1x
如果你检查这个网站,你可以发现它使用的是应用程序池的身份。

现在在IIS身份验证模块中:禁用“匿名身份验证”;启用“Windows身份验证”;启用“ASP.NET模拟”并设置您的用户。

完成此设置后,您可以看到它现在是用户“abc

相关问题