10

I need to enable Windows Authentication from my web.config, without setting it in IIS.

I have the following elements in the web.config:

  authentication mode="Windows
  identity impersonate="true 

However windows authentication is not working. How do I resolve this problem ?

Dimitar Dimitrov
  • 14,868
  • 8
  • 51
  • 79
zrabzdn
  • 1,345
  • 4
  • 11
  • 12

4 Answers4

15

For IIS Express

You can set it up here. You may also wish to disable anonymous access

Setting Windows auth for IIS Express

For IIS

I found it was necessary to set this under system.webServer

<system.webServer>
    […]
    <security>
      <authentication>
        <anonymousAuthentication enabled="false"/>
        <windowsAuthentication enabled="true"/>
      </authentication>
    </security>
  </system.webServer>

This does almost the same thing as the @Dimitar suggestion - use IIS Manager to change the setting. The difference is that the config file avoids a manual step - but adds this next one:

Note:

By default, IIS Feature Delegation locks some of those settings (Basic & Windows auth), so you'll need to go to the root of the IIS server, and enable those to be read/write. E.g.:

Feature delegation - Allowing read/write for auth section

A more detailed description of accessing Feature Delegation is here.

Community
  • 1
  • 1
Overflew
  • 7,872
  • 10
  • 45
  • 65
8

If by this you mean running your project from Visual Studio (IISExpress - not IIS), then you can try to do the following:

In Visual Studio -> Click on the root of your project -> Press F4 in order to open the properties pane -> Look for "Windows Authentication" and mark is as "Enabled" -> Run your project.

Dimitar Dimitrov
  • 14,868
  • 8
  • 51
  • 79
5

Unfortunately you must use IIS to enable Windows authentication. You cannot do it in Web.config alone. (At least up to IIS 8.5, the current version as of this post.)

This is because the Web.config elements for enabling Windows authentication (<system.webServer><security><authentication><windowsAuthentication>) can only be defined in applicationHost.config (C:\Windows\System32\inetsrv\config).

Keith
  • 20,636
  • 11
  • 84
  • 125
2

If windows authentication is not installed on IIS it won't work. If it is installed setting in web.config should be fine

Piotr Stapp
  • 19,392
  • 11
  • 68
  • 116