简体   繁体   English

在托管ASP.Net应用程序中无法区分的用户

[英]Users Indistinguishable in Hosted ASP.Net Application

I am working on a hosted ASP.Net application, with Windows Authentication, and I need to get the username for various personalisation tasks. 我正在使用Windows身份验证来开发托管的ASP.Net应用程序,并且需要获取用于各种个性化任务的用户名。 The directory on the host machine is set to have Windows Authentication and the web.config file also has:- 主机上的目录设置为具有Windows身份验证,并且web.config文件还具有:-

<authentication mode="Windows">
</authentication>

in it. 在里面。 I have tried various methods within the application to get the user name with the following results:- 我尝试了应用程序中的各种方法来获取具有以下结果的用户名:

Source                                                         Result
System.Web.HttpContext.Current.Request.LogonUserIdentity.Name  'EZ\urlname_a'
System.Environment.UserName                                    'NETWORK SERVICE'
System.Web.HttpContext.Current.User.Identity.Name              ''
this.Request.ServerVariables["LOGON_USER"]                     ''
this.Request.ServerVariables["AUTH_USER"]                      ''
this.User.Identity.Name                                        ''

thanks to the answers here , here , and here , among others. 感谢此处此处此处以及其他答案。 None of these distinguish between the various usernames that were entered. 这些都不能区分输入的各种用户名。

Is there anything else I can try in code to get the name (or some proxy for the name)? 我还能在代码中尝试获取名称(或名称的某些代理)吗? Is there anything I can check for in web.config ? 我可以在web.config检查什么吗? Or if I need to take the matter up with the host, is there any intelligent question I can ask? 或者,如果我需要与主持人接洽,是否有任何我想问的聪明问题?

Edit I have set the application directory and .Net version using the host's IIS Dialogue. 编辑我已经使用主机的IIS对话设置了应用程序目录和.Net版本。

You need to set IIS to use Windows Authentication only, then use Page.User.Identity.Name or similar to fetch the windows user name. 您需要将IIS设置为仅使用Windows身份验证,然后使用Page.User.Identity.Name或类似名称来获取Windows用户名。

From the Authentication pane, set the Windows Authentication to Enabled and Disable anonymous authentication. 在“身份验证”窗格中,将“ Windows身份验证”设置为“启用”和“禁用匿名身份验证”。

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

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