IIS 7.5/ASP.NET - 匿名访问除一个目录之外的所有内容 - 如何?

mk.*_*mk. 3 asp.net iis-7 ntfs iis-7.5

我们正在使用相同的应用程序从IIS 6和.NET 3.5升级到IIS 7.5(Windows Server 2008 R2 Enterprise).我无法让我们以前的IIS 6设置正常工作.

在IIS 6下,我可以设置网站本身为IIS本身使用特定的域用户(例如ourdomain\webuser).这控制了对所有文件的初始访问,包括HTML,图像等,并形成了初始请求,该请求转到ASP.NET页面,然后.NET引擎接管,运行.NET的用户是另一个域用户(例如我们的域名) dotnetuser).然后,我们将从IIS用户mydomain\webuser的一个文件夹(例如/ lockdown /)中获取所有NTFS权限.只要有人试图访问该目录中的文件,IIS就会说"无法访问,启动Windows身份验证访问"并提示他们输入凭据.这仍然导致任何底层.NET代码作为mydomain\dotnetuser运行.

我无法在IIS 7.5下使用相同的设置工作,并确信这只是一些愚蠢的疏忽.它......想要工作,但并不完全.这就是我所做的:

该站点的应用程序池设置为.NET Framework v2.0.50727,并选择"Integrated"作为托管管道模式选项.然后将标识设置为ourdomain\dotnetuser,以便池作为特定用户运行.

该网站设置为IIS>身份验证连接为"我们的域\ webuser",一切似乎都很好.麻烦的是我去了这个特殊/锁定/目录.我尝试将其设置为与IIS 6完全相同的方式(只需从ourdomain\webuser中删除对该文件夹的访问权限).当我这样做时,我确实获得了访问的标准提示,但在提供我的凭据后,我仍然得到:

Error message 401.3: You do not have permission to view this directory 
or page using the credentials you supplied (access denied due to Access 
Control Lists). Ask the Web server's administrator to give you access to 
'C:\ourwebsite\lockdown\default.aspx'.

我的帐户位于此计算机上的本地管理员组中(此处我是域管理员),并且管理员组已获得对此文件夹的完全访问权限.我在应用程序事件查看器中看到以下内容作为"信息"事件:

Event code: 4008 
Event message: File authorization failed for the request. 
Event time: 8/1/2010 8:45:18 AM 
Event time (UTC): 8/1/2010 12:45:18 PM 
Event ID: 0f8a5de692e74e67bb4e3c65a867586c 
Event sequence: 32 
Event occurrence: 1 
Event detail code: 0 

Application information: 
    Application domain: /LM/W3SVC/1/ROOT-1-129251371048714102 
    Trust level: Full 
    Application Virtual Path: / 
    Application Path: C:\ourwebsite\ 
    Machine name: TESTWEB3 

Process information: 
    Process ID: 3008 
    Process name: w3wp.exe 
    Account name: ourdomain\dotnetuser 

Request information: 
    Request URL: http://localhost/lockdown/default.aspx 
    Request path: /lockdown/default.aspx 
    User host address: ::1 
    User: ourdomain\myuser 
    Is authenticated: True 
    Authentication Type: Negotiate 
    Thread account name: ourdomain\dotnetuser

这里有任何建议或想法吗?

Car*_*res 5

您可以使用授权规则,只需使用以下内容在要保护的目录中创建web.config:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <security>
            <authorization>
                <remove users="*" roles="" verbs="" />
                <add accessType="Deny" users="?" />
                <add accessType="Allow" roles="Administrators" />
            </authorization>
        </security>
    </system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)

这将阻止对匿名用户的访问,并且仅允许来自Admnistrators组的用户.您可以使用角色或用户.