Reputation: 1299
How do I configure a project to use Windows Authentication? Now that there are no web.config files, I cannot see how to do this.
I see the app.UseIdentity() in Startup, but no idea how to use Windows Auth with IIS Express. When I try to create a project in IIS (Windows 7, IIS 7.5), there does not appear to be a .NET 4.6/4.5 app pool I tried .NET 4.0 but get an error:
Couldn't determine an appropriate version of runtime to run. See http://go.microsoft.com/fwlink/?LinkId=517742 for more information.
Of course, that link does not bring me to info, but to http://www.asp.net/
Upvotes: 6
Views: 5455
Reputation: 3884
What worked for me in debugging with VS2015:
Open the IIS Express config file: %userprofile%\Documents\IISExpress\config\applicationhost.config
There's a line that says:
<windowsAuthentication enabled="false">
Change it to:
<windowsAuthentication enabled="true">
Then I added to my Web.conf:
<authentication mode="Windows">
</authentication>
<authorization>
</authorization>
I was then able to pull the windows username with:
Request.LogonUserIdentity.Name
Upvotes: 6
Reputation: 3058
Go to web project properties -> Debug -> IIS Express Settings part and there uncheck Enable Anonymous Authentication and Check Enable Windows Authentication.
User (in controllers) will be loaded with local domain data.
http://screencast.com/t/GecnmVnXHC
edit:
We had to Enable Anonymous Authentication as a CORS preflight request would fail otherwise (401)
Upvotes: 1
Reputation: 186
There is a config file for IISExpress too. See a guide here: See Using Windows Authentication with IISExpress
Upvotes: -2