設定組 allowLocation 態區段的屬性。
語法
ConfigurationSection.SetAllowLocation(AllowLocation)
ConfigurationSection.SetAllowLocation(AllowLocation);
參數
| 名稱 | 定義 |
|---|---|
AllowLocation |
區分大小寫 string 的變數,可設定 allowLocation 組態區段的屬性。 可能的屬性值為 「true」 或 「false」。 預設為 "true"。 注意: 這個參數是 string ,而不是 boolean 。 |
傳回值
這個方法不會傳回值。
備註
屬性 allowLocation 會指定組態區段是否可以出現在一對位置標籤內。
因為 SetAllowLocation 是靜態方法,所以您應該藉由取得類別物件來呼叫它,如下列範例所示。
' Correct syntax:
Set oAnonAuth = oWebAdmin.Get("AnonymousAuthenticationSection")
oAnonAuth.SetAllowLocation "false"
下列語法會失敗,因為它嘗試在 類別的具體 Site 實例上呼叫 SetAllowLocation 。 呼叫 方法會導致 「SWbemObjectEx: 找不到」錯誤。
' Incorrect syntax:
Set oSite = oWebAdmin.Get("Site.Name='Default Web Site'")
oSite.GetSection "AnonymousAuthenticationSection", oAnonAuth
oAnonAuth.SetAllowLocation "false"
範例
下列範例會 allowLocation 設定匿名驗證組態區段的屬性。
' Get the WebAdministration namespace.
Set oWebAdmin = GetObject( _
"winmgmts:root\WebAdministration")
' Get the AnonymousAuthenticationSection.
Set oAnonAuth = oWebAdmin.Get( _
"AnonymousAuthenticationSection")
' Set the allowLocation attribute.
oAnonAuth.GetAllowLocation "false"
規格需求
| 類型 | 描述 |
|---|---|
| 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 |
另請參閱
AnonymousAuthenticationSection 類別
ConfigurationSection 類別
ConfigurationSection.GetAllowLocation 方法