Windows authentication in web.config in asp.net mvc4

I need to enable Windows authentication from my web.config without installing it in IIS.

I have the following elements in web.config :

  authentication mode="Windows identity impersonate="true 

However, Windows authentication does not work. How to solve this problem?

+4
source share
4 answers

If you mean starting your project from Visual Studio (IISExpress is not IIS), you can try the following:

In Visual Studio → Click on the root of your project → Press F4 to open the properties panel → Look for “Windows Authentication”, and mark it as “Enabled” → Run the project.

+7
source

For IIS Express

You can customize it here. You can also disable anonymous access.

Configure Windows auth for IIS Express

For IIS

I found it necessary to install this under system.webServer

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

This is almost the same as the @Dimitar suggestion - use IIS Manager to change the setting. The difference is that the configuration file avoids the manual step - but adds the following:

Note:

By default, the IIS function delegation function blocks some of these settings (Basic and Windows auth), so you need to go to the root directory of the IIS server and enable them for reading / writing. For instance:.

Feature Delegation - Read / Write Permission for the auth Section

A more detailed description of access to delegation of functions is here .

+5
source

Unfortunately, you must use IIS to enable Windows authentication. You cannot do this only in Web.config. (At least until IIS 8.5, the current version on this post.)

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

+2
source

If Windows Authentication is not installed on IIS, this will not work. If installed, the setup in web.config should be fine

0
source

Source: https://habr.com/ru/post/1483362/


All Articles