25

One web site is required to be accessed by me (developer) and one user (DOMAIN_NAME\USER_NAME).

When I developed web site in visual studio using "automatic host" created by VS, the following settings in web.config were enough:

<authentication mode="Windows"/>
<authorization>
  <allow users="DOMAIN_NAME\my_name,DOMAIN_NAME\USER_NAME" />
  <deny users="*" />
</authorization>

But when I created web site in IIS I'm receiving error:

Access is denied.

Description: An error occurred while accessing the resources required to serve this request. The server may not be configured for access to the requested URL.

Error message 401.2.: Unauthorized: Logon failed due to server configuration. Verify that you have permission to view this directory or page based on the credentials you supplied and the authentication methods enabled on the Web server. Contact the Web server's administrator for additional assistance.

What setting for ApplicationPoolIdentity and web site itself are required to be specified?

Thanks a lot!

EDIT:

I've configured Application Pool of local IIS to use 'LocalSystem' identity, web site - to use "pass-through" authentication, and as suggested disabled "Anonymous Authentication", enabled "Windows Authentication" - and web site locally became workable.

But locally I have windows 7 (IIS7), but on "TEST" environment (where I need to deploy web site) I have windows 2008 server and it doesn't have option to enable "Windows Authentication"... don't know why... probably that is for higher level of administrator, but I'm a member of Administrators group...

Guess, I'm doing something wrong...

Please advise.

Community
  • 1
  • 1
Budda
  • 18,015
  • 33
  • 124
  • 206

3 Answers3

45

Your web.config is set up properly. Further, ensure the IIS site/app is configured as:

  • to NOT allow anonymous access
  • forcing Integrated Windows authentication
  • leave the app pool as Network Service

IIS7

IIS6

Find the dialog below at

  • Control Panel / Administrative Tools -> IIS Manager -> Right click Web site -> Properties -> Directory Security

IIS 6 non anonymous with Windows Authentication

p.campbell
  • 98,673
  • 67
  • 256
  • 322
  • I tried to play with AppPoolIdentity, user name under which web site works - no result... – Budda May 17 '11 at 16:22
  • Network service - done, but can't find those dialogs that you showed. That should be done under windows server 2003... guess, that is IIS6 – Budda May 17 '11 at 16:41
  • 1
    I Appreciate your help, but when I right-click on web-site (on that machine on TEST) I don't see "Properties" Item. – Budda May 17 '11 at 16:51
  • It seems like IIS7 was setup to that machine... can't say exactly (our administrator is in vacation :) ) – Budda May 17 '11 at 16:52
  • Sorry, it is windows 2008 R2, not 2003... and IIS7 as a result. – Budda May 17 '11 at 17:24
  • http://weblogs.asp.net/zroiy/archive/2008/08/17/missing-windows-authentication-provider-for-iis-7-on-windows-server-2008.aspx - explanation, why I don't see that option! :) – Budda May 17 '11 at 17:31
  • 'select Windows Authentication ... disable Anonymous Authentication' - Thanks, saved my life!! – Jonathan May 28 '14 at 02:40
0

Maybe it can be useful: I started to receive 401.2. error in .ASPX application (no changes in the app made), in protected path amd Forms auth.:

<authentication mode="Forms">
...
</authentication>
...
<location path="Admin">
    <system.web>
        <authorization>
            <allow roles="Admin,Client" />
            <deny users="*" />
        </authorization>
    </system.web>
</location>

AFTER launching of other MVC applications on same computer/IIS. It seems MVC changed something in server's config (routes, I believe). Any playing with Authentication in IIS (computer/server/site) did not help. But Next helped: I have changed Application pool from .Net 4.5 to .Net 4.5 Classic for the web application. The difference in pool Managed pipeline mode, Integrated/Classic.

Thomas Guillerme
  • 1,747
  • 4
  • 16
  • 23
Michael
  • 1
  • 2
0

If you're using your Local IIS instead of IIS Express with Windows Authentication, make sure you have IIS ASP.NET features turned on and configured properly. (See https://stackoverflow.com/a/12867753/888792)

Also, when Visual Studio builds and publishes your website to an IIS Virtual Directory, you may need to Enable Windows Authentication and Disable Anonymous Authentication at the Parent Site Virtual Directory node level:

IIS-Windows-Authentication

CZahrobsky
  • 762
  • 7
  • 7