使用 Windows 身份验证禁用对 ASP.NET 应用程序的子文件夹的身份验证 [英] Disable authentication on subfolder(s) of an ASP.NET app using windows authentication

查看:22
本文介绍了使用 Windows 身份验证禁用对 ASP.NET 应用程序的子文件夹的身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用 windows 身份验证禁用 ASP.net 应用程序的一个或多个子文件夹上的 windows 身份验证?

Is it possible to disable windows authentication on one or more subfolders of an ASP.net application using windows authentication?

例如:

一个网站包含几个其他文件夹,其中包含整个应用程序的一部分:/frontend、/backend、/login

A website contains several other folders that contain parts of the overall application: /frontend, /backend, /login

bin 文件夹与这些子文件夹处于同一级别,即网站的根目录.

The bin folder is on the same level as these subfolder, i.e. the root of the website.

所有这些子文件夹都包含使用位于网站根目录的 bin 文件夹中的二进制文件的页面.

All of these subfolders contain pages that use binaries that reside in the bin folder of the root of the website.

用户在访问后端文件夹中的页面时必须输入 Windows 凭据,但在访问登录或前端文件夹中的页面时则不需要.

The user must input windows credentials when visiting a page in the backend folder, but not when visiting a page in the login or frontend folder.

我正在使用 IIS7

有什么想法吗?

推荐答案

找到解决方案:

  • 调整 applicationHost.config 文件并将overrideModeDefault"更改为Allow"对于 anonymousAuthentication en windowsAuthentication 部分条目

  • Adjusted the applicationHost.config file and changed the "overrideModeDefault" to "Allow" for the anonymousAuthentication en windowsAuthentication section entries

            <section name="anonymousAuthentication" type="System.WebServer.Configuration.AnonymousAuthenticationSection" overrideModeDefault="Allow" />
            <section name="windowsAuthentication" type="System.WebServer.Configuration.WindowsAuthenticationSection" overrideModeDefault="Allow" />

  • 在 web.config 中为需要从 Windows 身份验证中排除的每个文件夹/文件添加了位置标记

  • Added location tags in the web.config for every folder / file that needed to be excluded from windows authentication

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

  • 确保这些文件夹中的每一个都包含一个单独的 web.config 文件,以禁用身份模拟

  • Made sure each one of those folders contained a separate web.config file that disables identity impersonation

       <configuration>
        <system.web>
         <identity impersonate="false" />
        </system.web>
       </configuration>
    

  • 这篇关于使用 Windows 身份验证禁用对 ASP.NET 应用程序的子文件夹的身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆