Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2015 vNext and Windows Authentication

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/

like image 693
Outside the Box Developer Avatar asked Mar 24 '15 16:03

Outside the Box Developer


2 Answers

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

like image 83
Paul Avatar answered Oct 19 '22 22:10

Paul


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)

like image 38
pajics Avatar answered Oct 19 '22 23:10

pajics