简体   繁体   中英

getting domain user name without windows prompt using c#

I have an asp.net c# site that I have setup in IIS 7.

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.

I am using the follwing statement to get username:

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

I want to avoid windows prompting for login credentials.

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. 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. Otherwise, the login prompt is shown to prevent the information disclosure threat that Simon mentions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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