Asp – User.Identity.Name is not returning the correct credentials when using Windows Authentication in ASP.NET MVC

asp.netasp.net-mvcwindows-authentication

I am using Windows Authentication in my ASP.NET MVC application and I am prompted to enter credentials on my webserver which is a domain member [I have domain credentials and can authenticate fine] however when my controller action calls "User.Identity.Name" in an attempt to check a database value against the currently logged in user this is returning the SAM Account from the local machine and NOT the SAM account from the DOMAIN:

Local machine user name (which User.Identity.Name returns): LOCALPC\username

What I am expecting (which is what I am authenticating against AD as): DOMAIN\username

This causes me problems because I cannot accurately verify a user using only the username.

Am I missing something, is there a way to return what I am currently authenticated as to the webserver as opposed to what the local SAM account is on the client machine?

The reason this is important is because not all the intranet application clients will be domain joined (machines that aren't domain joined but belong to users with AD accounts).

Best Answer

When prompted in your web browser enter "DOMAIN\username" instead of just "username" for the authentication.

EDIT:

Is this a development server? Check the account that IIS is running on. Did you configure impersonation in web.config?

Related Topic