views:

740

answers:

4

In IIS7 under Windows Server 2008, I have a virtual directory with anonymous access off and Windows authentication on. In my web.config, I have:

<authentication mode="Windows"/>
<authorization>
      <allow roles="MYGROUP"/>
      <deny users="*"/>
</authorization>

and

<system.webServer>
    <!-- IIS7 security settings -->
    <security>
     <authorization>
       <add accessType="Deny" users="*"/>
       <add accessType="Allow" roles="MYGROUP"/>
     </authorization>
    </security>
</system.webServer>

Yet when I access default.aspx from IE and set a breakpoint in Global.asax.vb Application_AuthenticateRequest(), I get a null HttpContext.Current.User where I am expecting my own identity. It is almost as if Anonymous Access is on?

What can I do to troubleshoot this? Everything seems to work in IIS6.

A: 

II7 has integrated authentication. You can set it back to the old type by changing the Application Pool back to classical in the basic settings in IIS.

*Caution this is just an explanation and example, you may want to use the integrated authentication and do something different.

Yuriy Faktorovich
I must be missing something--IIS6 had "Integrated Windows Authentication" too. It is the first option under Authenticated Access in Directory Security > Authentication and access control > edit. What am I missing?
Patrick Szalapski
I didn't think what I am trying to do is "old type"--surely Microsoft isn't phasing out Windows Authentication. Where can I see info on the "new way" of doing authentication?
Patrick Szalapski
@Patrick: In II6 there were two levels of Authentication that were hit for each .NET request. First the windows one, then the ISAPI would find out it was a .NET request and then .NET would do its own Authentication. In IIS7 .NET was integrated into the Web Server and now there is only one Authentication. As far as I understand it. MSDN would likely be the unfortunate choice for the new way, if you don't want to go with the old way.
Yuriy Faktorovich
Does this new way have a name so that I can search for it? Everything I search for seems to be referring to the old way.
Patrick Szalapski
@Patrick: you can find it on msdn: In IIS 7, application pools run in one of two modes: integrated mode and classic mode. The application pool mode affects how the server processes requests for managed code, link: http://technet.microsoft.com/en-us/library/cc753449(WS.10).aspx
Yuriy Faktorovich
Clearly I'd like to stay in integrated mode, not classic mode, and then adjust my app to properly using Windows Authentication (or its successor functionality) in integrated mode. I see nothing anywhere on how to do this, do you know of any?
Patrick Szalapski
@Patrick: Unfortunately I haven't tried that yet, I was just showing how you could set it back to the old way(which I prefer, most likely because I'm use to it).
Yuriy Faktorovich
You should read information about classic vs integrated, see http://learn.iis.net/page.aspx/243/aspnet-integration-with-iis-7/ Integrated mode is much better, and it will have less duplication. The reason this used to work was because IIS would perform "AuthenticateRequest" way before ASP.NET would even see the request. In integrated, ASP.NET becomes 1st class in IIS and it will see the "BeginRequest and AuthenticateRequest" at the same time that IIS does. This causes some changes (correct changes I should add), which means some applications that leveraged the wrong behavior might fail.
CarlosAg
A: 

Having the same problems , can anyone shine some light?

Ybbest
A: 

The Same issue IIS 7
WIndows 7 64 vs2010

RTX
A: 

Anonymous access must be on if you don't use ssl or something your own security.

stdT