You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

IIS托管WCF的HTTPS服务使用<location>标签控制不同端点访问权限问题

你采用的通过IIS <location> 标签为不同svc服务端点配置独立Windows权限的方案是完全可行的,当前配置不生效是存在两处核心配置错误:

  • 路径配置错误:站点根目录下web.config的<location>标签path属性不需要填写站点名,你配置的Default Web Site/Service2.svc无法匹配实际请求路径,导致Service2.svc的权限规则不生效,默认继承了根目录仅允许xxx.luo访问的配置,所以xxx.luo2访问会返回401。
  • 账户属性配置错误:你当前用了roles属性配置单用户权限,roles对应的是Windows用户组,单个Windows账号需要用users属性指定,配置错误导致授权规则无法匹配到对应的访问用户。

解决步骤

  1. 修正根目录<system.webServer>下的授权规则,将roles改为users:
<authorization>
    <remove users="*" roles="" verbs="" />
    <add accessType="Allow" users="xxx.luo"/>
</authorization>
  1. 修正<location>节点的路径和授权配置:
<location path="Service2.svc" allowOverride="false" inheritInChildApplications="false">
    <system.webServer>
        <security>
            <authentication>
                <anonymousAuthentication enabled="false" />
                <windowsAuthentication  enabled="true"/>
            </authentication>
            <authorization>
                <remove users="*" roles="" verbs="" />
                <add accessType="Allow" users="xxx.luo2"/>
            </authorization>
        </security>
    </system.webServer>
</location>
  1. 可选优化:为了避免根目录规则变动影响Service1的权限,可额外新增Service1的独立<location>配置,明确指定仅xxx.luo可访问。
  2. 配置修改完成后,重启对应IIS站点,同时确认两个Windows账号都拥有站点物理目录的读取权限,避免文件系统权限导致的访问异常。

内容的提问来源于stack exchange,提问作者Zhijian Jim Luo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.09 06:27:00