简体   繁体   English

IIS 7如何保留网站子文件夹身份验证设置

[英]IIS 7 how to preserve website subfolder Authentication settings

In IIS you can set folder-level settings using the Features view (see screenshot). 在IIS中,您可以使用“功能”视图来设置文件夹级别的设置(请参见屏幕截图)。 I want to disable Anonymous authentication for several subfolders of my website and save those settings to source control. 我想为我的网站的几个子文件夹禁用匿名身份验证,然后将这些设置保存到源代码管理中。 I want to know where does IIS save these settings. 我想知道IIS在哪里保存这些设置。 They are not in the website web.config or the web.config inside subfolders. 它们不在网站web.config或子文件夹内的web.config中。 Is there anyway I can save the IIS settings with the source code or do I have to perform these tasks with each fresh deployement? 无论如何,我可以将IIS设置与源代码一起保存,还是必须在每次重新部署时执行这些任务?

设置文件夹认证

Add the following to your root web.config for each folder you want to secure: 将以下内容添加到您要保护的每个文件夹的根web.config中:

<location path="secure_folder">
    <system.webServer>
        <security>
            <authentication>
                <anonymousAuthentication enabled="false" />
                <basicAuthentication enabled="true" />
            </authentication>
        </security>
    </system.webServer>
</location>

The above assumes that you're using Basic Authentication. 以上假设您使用的是基本身份验证。

Alternatively create a web.config in each sub folder to be secured with pretty much the same (except without the <location> tag: 或者,在每个子文件夹中创建一个web.config ,以几乎相同的方式进行保护(除了没有<location>标记的情况之外:

<system.webServer>
    <security>
        <authentication>
            <anonymousAuthentication enabled="false" />
            <basicAuthentication enabled="true" />
        </authentication>
    </security>
</system.webServer>

If receive an error such as: 如果收到错误,例如:

There was an error while performing this operation. 执行此操作时出错。

Details: 细节:

Filename: \\?\\d:\\sites\\play1\\www\\web.config 文件名:\\?\\ d:\\ sites \\ play1 \\ www \\ web.config

Line number: 15 行号:15

Error: This configuration section cannot be used at this path. 错误:无法在此路径上使用此配置部分。 This happens when the section is locked at a parent level. 当节锁定在父级时,会发生这种情况。 Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false". 锁定默认情况下是(overrideModeDefault =“ Deny”),或者是由一个带有overlayMode =“ Deny”或旧版allowOverride =“ false”的位置标记显式设置的。

Then it means that the configuration settings for <anonymousAuthentication> and <basicAuthentication> haven't been delegated Read/Write permissions. 这意味着<anonymousAuthentication><basicAuthentication>的配置设置尚未被委派为“读/写”权限。

You can adjust this by launching IIS Manager and opening the Feature Delegation manager: 您可以通过启动IIS管理器并打开功能委托管理器来进行调整:

在此处输入图片说明

When you do this you'll see a list of features that can be controlled and their delegation state: 执行此操作时,您将看到可以控制的功能列表及其委派状态:

在此处输入图片说明

Right click on Authentication - Anonymous and select Read/Write . 右键单击Authentication - Anonymous然后选择Read/Write Do the same for Authentication - Basic . Authentication - Basic做同样的事情。

This feature delegation setting will be applied globally across all sites on the server, however it is possible to fine tune this to specific sites using Custom Site Delegation. 此功能委托设置将在服务器上的所有站点上全局应用,但是可以使用“自定义站点委托”将其微调到特定站点。

You can read more about IIS 7.x/8.0 Feature Delegation here: 您可以在此处阅读有关IIS 7.x / 8.0功能委托的更多信息:

http://www.iis.net/learn/manage/managing-your-configuration-settings/an-overview-of-feature-delegation-in-iis http://www.iis.net/learn/manage/managing-your-configuration-settings/an-overview-of-feature-delegation-in-iis

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM