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 ?

3
  • Do you need this to work from Visual Studio ? IISExpress ? Commented May 29, 2013 at 14:34
  • Which version of IIS? Commented May 29, 2013 at 14:46
  • I need this to work in iis 7.0 or 7.5 Commented May 29, 2013 at 17:38

4 Answers 4

16

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.

Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

6

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).

Comments

2

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.