共用方式為


ConfigurationSection.GetAllowDefinition 方法

allowDefinition 取組態區段的屬性。

語法

ConfigurationSection.GetAllowDefinition AllowDefinition  
ConfigurationSection.GetAllowDefinition(AllowDefinition);  

參數

名稱 定義
AllowDefinition 接收 string 方法傳回之屬性的 GetAllowDefinition 變數 allowDefinition 。 後續的一節會列出可能的屬性值。

傳回值

這個方法不會傳回值。

備註

allowDefinition 屬性會指定可在組態階層值中設定指定組態區段的位置。 這些屬性是在 ApplicationHost.config 檔案的 區段中指定 <configSections>

因為 GetAllowDefinition 是靜態方法,所以您應該藉由取得類別物件來呼叫它,如下列範例所示。

' Correct syntax:  
Set oAnonAuth = oWebAdmin.Get("AnonymousAuthenticationSection")  
oAnonAuth.GetAllowDefinition strAnonAuthAllowDefinition  

下列語法會失敗,因為它嘗試在 類別的具體 Site 實例上呼叫 GetAllowDefinition 。 呼叫 方法會導致 「SWbemObjectEx: 找不到」錯誤。

' Incorrect syntax:  
Set oSite = oWebAdmin.Get("Site.Name='Default Web Site'")  
oSite.GetSection "AnonymousAuthenticationSection", oAnonAuth  
oAnonAuth.GetAllowDefinition strAnonAuthAllowDefinition  

下表列出 屬性的 allowDefinition 可能值。

關鍵字 描述
Everywhere 區段可以在階層中的任何位置設定。
MachineOnly 區段只能在Machine.config檔案中設定。 注意:Machine.config檔案的預設位置是%systemroot% Microsoft.NET\Framework\version > \ <config\。
MachineToWebRoot 區段只能在Machine.config檔案或根Web.config檔案中設定。 注意:根Web.config檔案的預設位置是%systemroot% Microsoft.NET\Framework\version > \ <config\。
AppHostOnly 區段只能在ApplicationHost.config檔案中設定。
MachineToApplication 區段只能在全域層級設定。 對於.NET Framework區段,全域層級是根Web.config或Machine.config檔案;針對 IIS 區段,它是ApplicationHost.config檔案;而對於應用程式,則是根應用程式的Web.config檔案。

範例

下列範例會顯示 allowDefinition 匿名驗證組態區段的屬性。

' Get the WebAdministration namespace.  
Set oWebAdmin = GetObject( _  
    "winmgmts:root\WebAdministration")  
  
' Get the AnonymousAuthenticationSection.  
Set oAnonAuth = oWebAdmin.Get( _  
    "AnonymousAuthenticationSection")  
  
' Get the allowDefinition attribute.  
oAnonAuth.GetAllowDefinition strAnonAuthAllowDefinition  
  
' Display the allowDefinition attribute.  
WScript.Echo _  
    "Anonymous Authentication Allow Definition: " & _  
        strAnonAuthAllowDefinition  
  

規格需求

類型 描述
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 類別