如何使用带有web.config的IIS7中的基本身份验证,ip范围除外?

时间:2011-11-25 11:25:57

标签: exception authentication iis-7

我需要在IIS7服务器上进行一些基本身份验证,但我不希望它显示在192.168.0.x范围内。

对于.htaccess,它会是这样的:

Deny from all
Order deny,allow

AuthName "myauth"
AuthUserFile .htpasswd
AuthType Basic
Require valid-user
Allow from 192.168.0.
Satisfy Any

THX〜

1 个答案:

答案 0 :(得分:1)

这样的事情可以吗?:

<configuration>
  <location path="..">
    <system.webServer>
      <security>

        <authentication>
          <anonymousAuthentication enabled="false" />
          <basicAuthentication enabled="true" />
        </authentication>

        <ipSecurity allowUnlisted="false"> 
          <add ipAddress="192.168.100.0" subnetMask="255.255.255.0" allowed="true"/>
        </ipSecurity>

      </security>
    </system.webServer>
  </location>
</configuration>