简体   繁体   English

ASP.Net应用程序-Windows身份验证不显示当前登录的用户名,但显示网络服务

[英]ASP.Net application - Windows authentication NOT showing current logged-in usernames but NETWORK SERVICE

We've few ASP.Net v2.0 intranet applications running with Windows Authentication. 我们很少有使用Windows身份验证运行的ASP.Net v2.0内部网应用程序。 Recently the servers were moved from on-premises datacenter to AWS (Amazon Web Services). 最近,服务器已从本地数据中心移至AWS(Amazon Web Services)。 After the move, everything seems to be working as-is except for the welcome message which is now showing “Hello NETWORK SERVICE” instead of the name of the logged in user. 移动之后,除了欢迎消息(现在显示“ Hello NETWORK SERVICE”而不是已登录用户的名称)外,其他所有内容似乎都按原样工作。

In IIS Authentication settings, only Windows Authentication is enabled with all others options including “ASP.Net Impersonation” disabled. 在IIS身份验证设置中,仅启用Windows身份验证,并禁用所有其他选项,包括“ ASP.Net模拟”。 Tried running Application Pool with both ApplicationPoolIdentity and NetworkService but same results. 尝试同时运行带有ApplicationPoolIdentity和NetworkService的Application Pool,但结果相同。 The way current username is fetched in code is; 在代码中获取当前用户名的方式是:

System.Web.HttpContext.Current.User.Identity.Name;

Any idea what needs to be changed to get it back to previous behavior where it showed current logged-in user name instead of NETWORK SERVICE? 是否知道需要更改什么才能使其恢复到以前的行为,即显示当前登录的用户名而不是NETWORK SERVICE? Thanks! 谢谢!

对于WebForms,应阅读Page.User;对于MVC,应阅读Controller.User。

It turned out that someone had messed around with IIS settings so to fix it I did below steps; 事实证明,有人弄乱了IIS设置,因此要解决此问题,我按照以下步骤进行了操作;

  1. Go to the web application in IIS 转到IIS中的Web应用程序
  2. Open Configuration Editor 打开配置编辑器
  3. Change Section to system.webServer/serverRuntime 将部分更改为system.webServer / serverRuntime
  4. Change authenticatedUserOverride to UseAuthenticatedUser (for me it was set to UseWorkerProcessUser) 将authenticatedUserOverride更改为UseAuthenticatedUser(对我而言,它已设置为UseWorkerProcessUser)

For further details refer to below link; 有关更多详细信息,请参见下面的链接; https://blogs.iis.net/jaroslad/what-does-the-authenticateduseroverrideuser-do https://blogs.iis.net/jaroslad/what-does-the-authenticateduseroverrideuser-do

screenshot of the configuration 1 配置1的屏幕截图

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM