HandlersSection クラス

URL のハンドラーを格納します。

構文

class HandlersSection : ConfigurationSectionWithCollection  

メソッド

次の表に、HandlersSection クラスによって公開されるメソッドの一覧を示します。

名前 説明
[追加] (ConfigurationSectionWithCollection から継承。)
Clear (ConfigurationSectionWithCollection から継承。)
Get (ConfigurationSectionWithCollection から継承。)
GetAllowDefinition (ConfigurationSection から継承。)
GetAllowLocation (ConfigurationSection から継承。)
削除 (ConfigurationSectionWithCollection から継承。)
RevertToParent (ConfigurationSection から継承。)
SetAllowDefinition (ConfigurationSection から継承。)
SetAllowLocation (ConfigurationSection から継承。)

プロパティ

次の表は、HandlersSection クラスによって公開されるプロパティの一覧です。

名前 説明
AccessPolicy ハンドラーのアクセス ポリシーを指定する sint32。 使用できる値の一覧は、後述の「注釈」セクションに示します。
Handlers HandlerAction オブジェクトの配列。
Location (ConfigurationSection から継承。)キー プロパティ。
Path (ConfigurationSection から継承。)キー プロパティ。
SectionInformation (ConfigurationSection から継承。)

サブクラス

このクラスにはサブクラスが含まれていません。

解説

このクラスは、ApplicationHost.config ファイルの <handlers> セクションに対応します。

次の表に、AccessPolicy プロパティとして使用できる値の一覧を示します。 既定値は 1 (Read) です。

Value キーワード 説明
0 None ハンドラーには権限がありません。
1 Read ハンドラーには、フォルダーのファイルまたはコンテンツに対する読み取りアクセス許可があります。 注: このフラグは IIS 6.0 で AccessRead という名前が付けられました。
2 Write ハンドラーは、サーバー上の有効なディレクトリに書き込んだり、書き込みが有効なファイルのコンテンツを変更したりできます。 注: このフラグは IIS 6.0 で AccessWrite という名前が付けられました。
4 Execute ハンドラーは、ファイルの種類に関係なく、フォルダーのファイルまたはコンテンツを実行できます。 注: このフラグは IIS 6.0 で AccessExecute という名前が付けられました。
16 Source ハンドラーは、Read または Write のいずれかのフラグが設定されている場合に、スクリプトのソース コードにアクセスできます。 Read が設定されている場合、ハンドラーはソース コードを読み取ることができます。 Write が設定されている場合、ハンドラーはソース コードに書き込むことができます。 ReadWrite もどちらも設定されていない場合、Source フラグは使用できません。 注: このフラグは IIS 6.0 で AccessSource という名前が付けられました。
512 Script このハンドラーは、スクリプトを実行できます。 注: このフラグは IIS 6.0 で AccessScript という名前が付けられました。
1024 NoRemoteWrite このハンドラーは、リモートで書き込むことができません。 ファイルを作成または変更するためのリモート要求は拒否されます。 Write フラグも設定されている場合は、IIS Web サーバーを実行しているコンピューターからの要求のみが成功します。 注: このフラグは IIS 6.0 で AccessNoRemoteWrite という名前が付けられました。
4096 NoRemoteRead このハンドラーは、リモートで読み取ることができません。 ファイルを表示するためのリモート要求は拒否されます。 Read フラグも設定されている場合は、IIS Web サーバーを実行しているコンピューターからの要求のみが成功します。 注: このフラグは IIS 6.0 で AccessNoRemoteRead という名前が付けられました。
8192 NoRemoteExecute このハンドラーは、リモートで実行することができません。 アプリケーションを実行するためのリモート要求は拒否されます。 Execute フラグも設定されている場合は、IIS Web サーバーを実行しているコンピューターからの要求のみが成功します。 注: このフラグは IIS 6.0 で AccessNoRemoteExecute という名前が付けられました。
16384 NoRemoteScript このハンドラーは、リモートでスクリプトを実行することができません。 動的コンテンツを実行するリモート要求は拒否されます。 Script フラグも設定されている場合は、IIS Web サーバーを実行しているコンピューターからの要求のみが成功します。 注: このフラグは IIS 6.0 で AccessNoRemoteScript という名前が付けられました。

次の例は、<handlers> セクションに対してハンドラーを追加および削除します。

Note

構成要素を追加または削除すると、基になる構成セクションは変更されますが、構成セクションを表すスクリプト内のオブジェクト変数は変更されません。 スクリプトに変更が表示されるには、変更後にオブジェクト変数に対して WMI の Refresh_ メソッドを呼び出す必要があります。 これにより、構成ストアの最新のデータでオブジェクト変数が更新されます。

' ----------------------------------------------------------  
' The first example adds a handler to the <handlers> section.  
' ----------------------------------------------------------  
' Connect to the WMI WebAdministration namespace.  
Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")  
  
' Get the <handlers> section.  
Set oSite = oWebAdmin.Get("Site.Name='Default Web Site'")  
oSite.GetSection "HandlersSection", oHandlersSection  
  
' Display the old handler names.  
WScript.Echo "---[Old Handler List]---"  
Call DisplayHandlers  
  
' Create a new handler.  
Set oHandler = oWebAdmin.Get("HandlerAction").SpawnInstance_  
oHandler.Name = "NewHandler"   
oHandler.Path="*.stm"   
oHandler.Verb="GET,POST"   
oHandler.Modules="ServerSideIncludeModule"   
  
' Add the handler to the <handlers> section.  
oHandlersSection.Add "Handlers", oHandler  
  
' Call the WMI Refresh_ method to update the oHandlersSection object.  
oHandlersSection.Refresh_  
  
' Display the new handler names.   
WScript.Echo "---[New Handler List]---"  
Call DisplayHandlers  
  
' ----------------------------------------------------------------  
' The second example removes a handler by using the handler name.  
' ----------------------------------------------------------------  
' Connect to the WMI WebAdministration namespace.  
Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")  
  
' Get the <handlers> section.  
Set oSite = oWebAdmin.Get("Site.Name='Default Web Site'")  
oSite.GetSection "HandlersSection", oHandlersSection  
  
' Display the old handler names.  
WScript.Echo "---[Old Handler List]---"  
Call DisplayHandlers  
  
' Remove the CGI-exe handler by name.  
For Each oHandler In oHandlersSection.Handlers  
     If oHandler.Name = "CGI-exe" Then  
        oHandlersSection.Remove "Handlers", oHandler  
    End If   
Next  
  
' Call the WMI Refresh_ method to update the oHandlersSection object.  
oHandlersSection.Refresh_  
  
' Display the new list of handler names.   
WScript.Echo "---[New Handler List]---"  
Call DisplayHandlers  
  
' This is the sub that displays the handler names.  
Sub DisplayHandlers  
    WScript.Echo   
    For Each oHandler In oHandlersSection.Handlers  
        WScript.Echo "Handler Name: " & oHandler.Name  
    Next  
End Sub  
  

継承階層

ConfigurationSection

ConfigurationSectionWithCollection

HandlersSection

要件

説明
クライアント - 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
Product - IIS 7.0、IIS 7.5、IIS 8.0、IIS 8.5、IIS 10.0
MOF ファイル WebAdministration.mof

参照

ConfigurationSectionWithCollection クラス
HandlerAction クラス