简体   繁体   English

使用c#获取没有Windows提示符的域用户名

[英]getting domain user name without windows prompt using c#

I have an asp.net c# site that I have setup in IIS 7. 我有一个我在IIS 7中设置的asp.net c#站点。

In IIS I have enabled basic and windows authentication so I can get the domain users username, so if there is a way to get this without prompting that'd be a perfect solution for me. 在IIS中,我启用了基本身份验证和Windows身份验证,因此我可以获取域用户的用户名,因此如果有办法获得此功能而不提示这对我来说是一个完美的解决方案。

I am using the follwing statement to get username: 我使用follwing语句来获取用户名:

String username = System.Web.HttpContext.Current.User.Identity.Name;
lblUserName.Text = "Welcome" + username;

I want to avoid windows prompting for login credentials. 我想避免Windows提示登录凭据。

Can you please give me suggestions how can i do this? 你能告诉我如何做到这一点吗?

The only way the server can know the visiting user's name is if that user authenticates using their Windows credentials. 服务器可以知道访问用户名称的唯一方法是该用户是否使用其Windows凭据进行身份验证。 By default, IE and Chrome will do so without a prompt if and only if the site in question is located in the Intranet security zone. 默认情况下, 当且仅当相关站点位于Intranet安全区域时,IE和Chrome才会在没有提示的情况下执行此操作。 Otherwise, the login prompt is shown to prevent the information disclosure threat that Simon mentions. 否则,将显示登录提示以防止Simon提及的信息泄露威胁。

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

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