Get the computer user name in a web application

2019-07-19 15:40发布

问题:

I have a web application where forms authentication is used. The user names are the same that the ones used by the users in their computers, so they want the web app to be able to detect that user name so the app can log it the user automatically.

How can it be done? I mean, if I set the authentication mode to "Form" do I still get those credentials from IIS?

I know this can be done in several better ways than this, but I am interested in this particular way. As it is a small web app in an intranet with a few users doesn't worth it a big architectural change. If it's possible, happy days, otherwise it will have to wait.

Cheers.

回答1:

That cannot be done with Forms Authentication. Without prompting the client for credentials, there is no way to retrieve that information from the client's machine.



回答2:

Windows auth cannot coexists with Forms auth, but it can coexists with Anonymous auth.

More info here: Windows authentication is not challenging browsers out of the domain