アプリケーションの依存関係 <applicationDependencies>

  • 概要
  • 互換性
  • セットアップ
  • 方法
  • 構成
  • サンプル コード

概要

<security> 要素の <applicationDependencies> 要素は、<isapiCgiRestriction> 要素と連携して機能します。これらの要素によって、1 つ以上の CGI または ISAPI 拡張制限に依存するアプリケーションが定義されます。<applicationDependencies> 要素にアプリケーションが指定されている場合、そのアプリケーションは <isapiCgiRestriction> 要素内の 1 つ (または複数) の項目に依存します。

互換性

  IIS 7.0 IIS 6.0
注意 <security><applicationDependencies> は IIS 7.0 で新たに導入された要素です。 <applicationDependencies> 要素は、IIS 6.0 の IIsWebService メタベース オブジェクトの ApplicationDependencies 属性に代わるものです。

セットアップ

<applicationDependencies> 要素は、IIS 7.0 の既定のインストールに含まれています。

方法

IIS 7.0 で <applicationDependencies> 要素を構成するためのユーザー インターフェイスはありません。<applicationDependencies> 要素をプログラムによって構成する方法の例については、このドキュメントの「サンプル コード」セクションを参照してください。

構成

属性

なし。

子要素

要素 説明
application オプションの要素。

CGI または ISAPI 拡張制限に依存するアプリケーションを指定します。
clear オプションの要素。

applicationDependencies コレクションからアプリケーションに対するすべての参照を削除します。

構成サンプル

次の構成サンプルは、IIS 7.0 への Active Server Pages (ASP) とカスタム アプリケーションのインストール後、Default Web Site の <applicationDependencies> 要素に設定されたアプリケーションの依存関係と、<isapiCgiRestriction> の関連するエントリを示しています。

  • Active Server Pages アプリケーションは "ASP" ISAPI/CGI 制限グループに依存しています。
  • カスタム アプリケーションは、"MyCustomGroup" ISAPI/CGI 制限グループに依存し、また ASP ISAPI/CGI 制限グループにも依存しています。
<system.webServer>
   <security>
      <isapiCgiRestriction notListedIsapisAllowed="false" notListedCgisAllowed="false">
         <clear />

         <add allowed="true" groupId="ASP"
            path="C:\Windows\system32\inetsrv\asp.dll" 
            description="Active Server Pages" />
         <add allowed="true" groupId="MyCustomGroup"
            path="C:\Windows\system32\inetsrv\mycustom.dll"
            description="My Custom Application" />
      </isapiCgiRestriction>
   </security>
</system.webServer>

<location path="Default Web Site">

   <system.webServer>
      <security>
         <applicationDependencies>
            <application name="My Custom Application" groupId="MyCustomGroup">
               <add groupId="ASP" />
            </application>

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

サンプル コード

次の構成サンプルは、Default Web Site の <applicationDependencies> 要素に設定されたアプリケーションの依存関係を示しています。カスタム アプリケーションは、"MyCustomGroup" ISAPI/CGI 制限グループに依存し、また ASP ISAPI/CGI 制限グループにも依存しています。

AppCmd.exe

appcmd.exe set config "Default Web Site" -section:system.webServer/security/applicationDependencies /+"[name='My Custom Application',groupId='MyCustomGroup']" /commit:apphost

appcmd.exe set config "Default Web Site" -section:system.webServer/security/applicationDependencies /+"[name='My Custom Application',groupId='MyCustomGroup'].[groupId='ASP']" /commit:apphost

C#

using System;
using System.Text;
using Microsoft.Web.Administration;

internal static class Sample
{
   private static void Main()
   {
      using (ServerManager serverManager = new ServerManager())
      {
         Configuration config = serverManager.GetApplicationHostConfiguration();
         ConfigurationSection applicationDependenciesSection = config.GetSection("system.webServer/security/applicationDependencies", "Default Web Site");

         ConfigurationElementCollection applicationDependenciesCollection = applicationDependenciesSection.GetCollection();
         ConfigurationElement applicationElement = applicationDependenciesCollection.CreateElement("application");
         applicationElement["name"] = @"My Custom Application";
         applicationElement["groupId"] = @"MyCustomGroup";

         ConfigurationElementCollection applicationCollection = applicationElement.GetCollection();
         ConfigurationElement addElement = applicationCollection.CreateElement("add");
         addElement["groupId"] = @"ASP";
         applicationCollection.Add(addElement);
         applicationDependenciesCollection.Add(applicationElement);

         serverManager.CommitChanges();
      }
   }
}

VB.NET

Imports System
Imports System.Text
Imports Microsoft.Web.Administration

Module Sample

   Sub Main()
      Dim serverManager As ServerManager = New ServerManager
      Dim config As Configuration = serverManager.GetApplicationHostConfiguration
      Dim applicationDependenciesSection As ConfigurationSection = config.GetSection("system.webServer/security/applicationDependencies", "Default Web Site")

      Dim applicationDependenciesCollection As ConfigurationElementCollection = applicationDependenciesSection.GetCollection
      Dim applicationElement As ConfigurationElement = applicationDependenciesCollection.CreateElement("application")
      applicationElement("name") = "My Custom Application"
      applicationElement("groupId") = "MyCustomGroup"

      Dim applicationCollection As ConfigurationElementCollection = applicationElement.GetCollection
      Dim addElement As ConfigurationElement = applicationCollection.CreateElement("add")
      addElement("groupId") = "ASP"
      applicationCollection.Add(addElement)
      applicationDependenciesCollection.Add(applicationElement)

      serverManager.CommitChanges()
   End Sub

End Module

JavaScript

var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST";
var applicationDependenciesSection = adminManager.GetAdminSection("system.webServer/security/applicationDependencies", "MACHINE/WEBROOT/APPHOST/Default Web Site");

var applicationDependenciesCollection = applicationDependenciesSection.Collection;
var applicationElement = applicationDependenciesCollection.CreateNewElement("application");
applicationElement.Properties.Item("name").Value = "My Custom Application";
applicationElement.Properties.Item("groupId").Value = "MyCustomGroup";

var applicationCollection = applicationElement.Collection;
var addElement = applicationCollection.CreateNewElement("add");
addElement.Properties.Item("groupId").Value = "ASP";
applicationCollection.AddElement(addElement);
applicationDependenciesCollection.AddElement(applicationElement);

adminManager.CommitChanges();

VBScript

Set adminManager = WScript.CreateObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"
Set applicationDependenciesSection = adminManager.GetAdminSection("system.webServer/security/applicationDependencies", "MACHINE/WEBROOT/APPHOST/Default Web Site")

Set applicationDependenciesCollection = applicationDependenciesSection.Collection
Set applicationElement = applicationDependenciesCollection.CreateNewElement("application")
applicationElement.Properties.Item("name").Value = "My Custom Application"
applicationElement.Properties.Item("groupId").Value = "MyCustomGroup"

Set applicationCollection = applicationElement.Collection
Set addElement = applicationCollection.CreateNewElement("add")
addElement.Properties.Item("groupId").Value = "ASP"
applicationCollection.AddElement(addElement)
applicationDependenciesCollection.AddElement(applicationElement)

adminManager.CommitChanges()