共用方式為


IPSecuritySection 類別

根據 IP 位址相關資訊設定 Web 服務器內容的存取權。

Syntax

class IPSecuritySection : ConfigurationSectionWithCollection  

方法

下表列出 類別所 IPSecuritySection 公開的方法。

名稱 描述
加入 (繼承自 ConfigurationSectionWithCollection.)
清除 (繼承自 ConfigurationSectionWithCollection。)
Get (繼承自 ConfigurationSectionWithCollection。)
GetAllowDefinition (繼承自 ConfigurationSection.)
GetAllowLocation (繼承自 ConfigurationSection。)
移除 (繼承自 ConfigurationSectionWithCollection。)
RevertToParent (繼承自 ConfigurationSection。)
SetAllowDefinition (繼承自 ConfigurationSection。)
SetAllowLocation (繼承自 ConfigurationSection。)

屬性

下表列出 類別所 IPSecuritySection 公開的屬性。

名稱 描述
AllowUnlisted 讀取/寫入 boolean 值。 true 如果存取權被授與屬性中 IPAddressFilters 未指定的 IP 位址、功能變數名稱和子網路遮罩組合,則為 , false 否則為 。 預設值為 true。 這個屬性會依序處理。 注意: 如果您使用本機主機位址 (127.0.0.1) 且 AllowUnlisted 屬性設定 false 為 ,除非將 127.0.0.1 指定為專案,否則使用者將會遭到拒絕存取,除非將 127.0.0.1 指定為 IPSecurityAllowedtrue 專案。
EnableReverseDNS 讀取/寫入 boolean 值。 true 如果執行反向 DNS 查閱來驗證 IP 位址解析的功能變數名稱;否則為 false 。 預設值為 false注意: 啟用此屬性時,IIS 必須解析每個用戶端 IP 位址的 DNS 名稱。 單一 DNS 查閱可能需要幾秒鐘的時間,而且 IIS 必須等到功能變數名稱可以驗證為止。 在規劃大規模實作時,您應該考慮此行為。
IpSecurity 讀取/寫入 IPAddressFilterElement 值的陣列,指定授與或拒絕存取權的 IP 位址、功能變數名稱和子網屏蔽組合。 注意: 此屬性中的專案會依序處理。 最佳做法是先將要拒絕的專案放在清單中。
Location (繼承自 ConfigurationSection .) 索引鍵屬性。
Path (繼承自 ConfigurationSection .) 索引鍵屬性。
SectionInformation (繼承自 ConfigurationSection。)

子類別

這個類別不包含子類別。

備註

在 IIS 6.0 中,已個別授與或拒絕 URL。 不過,在 IIS 7 中,會繼承存取規則,併合並其語意來判斷最終存取,這就是為什麼規則順序很重要的原因。

範例

下列範例會顯示 IPSecuritySection 預設網站的設定。

' Connect to the WMI WebAdministration namespace.  
Set oWebAdmin = _  
    GetObject("winmgmts:root\WebAdministration")  
  
' Get the IP security section for the default Web site.  
Set oSite = oWebAdmin.Get("Site.Name='Default Web Site'")  
oSite.GetSection "IPSecuritySection", oSection  
  
' Display the Path and Location properties.  
WScript.Echo "=============================="  
WScript.Echo "IP Security Section Properties"  
WScript.Echo "=============================="  
WScript.Echo "Path: " & oSection.Path  
WScript.Echo "Location: " & oSection.Location  
WScript.Echo  
  
' Display the AllowUnlisted and   
' EnableReverseDns properties.  
WScript.Echo "AllowUnlisted: " & oSection.AllowUnlisted  
WScript.Echo "EnableReverseDns: " & _  
                oSection.EnableReverseDns  
WScript.Echo  
  
' Display the IP and domain restrictions.  
WScript.Echo "--------------------------"  
WScript.Echo "IP and domain restrictions"  
WScript.Echo "--------------------------"  
For Each oIPAddressFilter In oSection.IpSecurity  
    WScript.Echo "IpAddress: " & oIPAddressFilter.IpAddress      
    WScript.Echo "DomainName: " & _  
        oIPAddressFilter.DomainName  
    WScript.Echo "SubnetMask: " & _  
        oIPAddressFilter.SubnetMask  
    WScript.Echo "Allowed: " & oIPAddressFilter.Allowed  
    WScript.Echo  
Next  
  

繼承階層架構

ConfigurationSection

ConfigurationSectionWithCollection

IPSecuritySection

規格需求

類型 描述
Client - Windows Vista 上的 IIS 7.0
- Windows 7 上的 IIS 7.5
- Windows 8 上的 IIS 8.0
- Windows 10上的 IIS 10.0
伺服器 - Windows Server 2008 上的 IIS 7.0
- Windows Server 2008 R2 上的 IIS 7.5
- Windows Server 2012 上的 IIS 8.0
- Windows Server 2012 R2 上的 IIS 8.5
- Windows Server 2016上的 IIS 10.0
產品 - IIS 7.0、IIS 7.5、IIS 8.0、IIS 8.5、IIS 10.0
MOF 檔案 WebAdministration.mof

另請參閱

ConfigurationSectionWithCollection 類別
IPAddressFilterElement 類別