gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 11:07:59 24 4
gpt4 key购买 nike

我们正在使用相同的应用程序从 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 的用户是另一个域用户(例如 ourdomain\点网用户)。然后,我们将从 IIS 用户 ourdomain\webuser 的一个文件夹(例如/lockdown/)中提取所有 NTFS 权限。任何时候有人试图访问该目录中的文件时,IIS 都会说“无权访问,启动 Windows 身份验证访问”并提示他们输入凭据。这仍然会导致任何底层 .NET 代码作为 ourdomain\dotnetuser 运行。

我在使相同的设置在 IIS 7.5 下工作时遇到了麻烦,我确信这只是一些愚蠢的疏忽。它...想要工作但不完全。这是我所做的:

站点的应用程序池设置为 .NET Framework v2.0.50727,并选择“集成”作为托管管道模式选项。然后将身份设置为 ourdomain\dotnetuser,以便池以该特定用户身份运行。

该网站设置为 IIS > 身份验证以连接为“ourdomain\webuser”,一切似乎都很好。问题是当我进入这个特殊的/lockdown/目录时。我试图以与 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

这里有什么建议或想法吗?

最佳答案

您可以为此使用授权规则,只需在您要保护的目录中创建一个 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>

这将阻止对匿名用户的访问,并且只允许 Admnistrators 组的用户访问。您可以为此使用角色或用户。

关于asp.net - IIS 7.5/ASP.NET - 匿名访问除一个目录之外的所有内容 - 如何?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3382086/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com