セキュリティ <security>

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

※本ページに挿入されている画像をクリックすると、画像全体が別ウィンドウで表示されます。

概要

<security> セクション グループは <system.webServer> セクション内に属し、インターネット インフォメーション サービス (IIS) 7.0 サーバー上のセキュリティ設定を構成するすべての要素を含みます。これらの設定には、サイトの SSL (Secure Sockets Layer) 設定、CGI (Common Gateway Interface) または ISAPI (Internet Server API) バイナリに依存するアプリケーション、サーバーにインストールされているすべての認証モジュールの構成設定、承認規則の設定などがあります。また、IP セキュリティおよび要求のフィルタリングの構成設定や、サーバーの ISAPI および CGI の制限の一覧も含まれます。

<security> セクション グループ内の設定を組み合わせることで、より高いセキュリティが得られます。以下に例を示します。

  • <authentication> 要素は、IIS 7.0 サーバーにインストールして有効にできるすべてのユーザー認証の種類の構成セクションを定義します。<authorization> 要素は、サイトまたはアプリケーションにアクセスできるユーザー アカウントを構成します。<authorization><authentication> と組み合わせて使用することで、サーバー上のコンテンツへのアクセスをセキュリティで保護することが可能です。<access> 要素は、Web サーバー、サイト、またはアプリケーションの SSL 設定を構成します。
  • <isapiCgiRestriction> 要素は、IIS 7.0 上で実行できる CGI および ISAPI アプリケーションの一覧を指定します。この要素を使用すると、悪意のあるユーザーが承認されていない CGI や ISAPI バイナリを Web サーバーにコピーして実行するのを防止することができます。<applicationDependencies> 要素は、1 つ以上の CGI または ISAPI 拡張制限に依存するアプリケーションを指定します。<isapiCgiRestriction> 要素を <applicationDependencies> 要素と組み合わせて使用することで、CGI または ISAPI 拡張制限を適切に設定することができます。

: セキュリティを強化するために、Windows Vista および Windows Server 2008 では IIS 7.0 は既定ではインストールされません。また、IIS 7.0 をインストールする場合、IIS は HTML ファイルやイメージ ファイルなどの静的コンテンツのみを提供するように自動的に構成されます。Web サイトおよびアプリケーションに必要なその他の役割サービスおよび機能は手動でインストールする必要があります。この手法により、IIS 7.0 の攻撃対象領域が大幅に削減されます。

互換性

  IIS 7.0 IIS 6.0
説明 <security> は IIS 7.0 で新たに導入された要素です。

<security> 要素は、IIS 6.0 の証明書、認証、および承認に関連した security メタベース プロパティに代わるものです。

セットアップ

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

方法

匿名認証を無効にする方法

  1. タスク バーの [スタート] ボタンをクリックして、[管理ツール] をポイントし、[インターネット インフォメーション サービス (IIS) マネージャー] をクリックします。

  2. [接続] ウィンドウで当該サーバー名を展開して [サイト] を展開し、ツリー表示内の構成対象のレベルに移動して、Web サイトまたは Web アプリケーションをクリックします。

  3. [ホーム] ウィンドウで、[セキュリティ] セクションまでスクロールして [認証] をダブルクリックします。

  4. [認証] ウィンドウで [匿名認証] を選択し、[操作] ウィンドウの [無効にする] をクリックします。

    拡大

匿名認証の資格情報を IUSR アカウントから変更する方法

  1. タスク バーの [スタート] ボタンをクリックして、[管理ツール] をポイントし、[インターネット インフォメーション サービス (IIS) マネージャー] をクリックします。
  2. [接続] ウィンドウで当該サーバー名を展開して [サイト] を展開し、ツリー表示内の構成対象のレベルに移動して、Web サイトまたは Web アプリケーションをクリックします。
  3. [ホーム] ウィンドウで、[セキュリティ] セクションまでスクロールして [認証] をダブルクリックします。
  4. [認証] ウィンドウで [匿名認証] を選択し、[操作] ウィンドウの [編集] をクリックします。
  5. [匿名認証資格情報の編集] ダイアログ ボックスで、次のいずれかの操作を行います。
    • アプリケーション プール用に設定された ID を使用する場合は、[アプリケーション プール ID] を選択して、[OK] をクリックします。

      拡大

    • [設定] をクリックし、[資格情報の設定] ダイアログ ボックスで、[ユーザー名] ボックスにアカウントのユーザー名を入力し、[パスワード] および [パスワードの確認] ボックスにアカウントのパスワードを入力して、[OK] を 2 回クリックします。

      拡大 : この手順を実行する場合、新しいアカウントに付与する特権は、IIS サーバー コンピューター上での最小限の特権に制限してください。

基本認証を有効にして匿名認証を無効にする方法

  1. タスク バーの [スタート] ボタンをクリックして、[管理ツール] をポイントし、[インターネット インフォメーション サービス (IIS) マネージャー] をクリックします。

  2. [接続] ウィンドウで当該サーバー名を展開して [サイト] を展開し、基本認証を有効にする Web サイト、Web アプリケーション、または Web サービスをクリックします。

  3. [ホーム] ウィンドウで、[セキュリティ] セクションまでスクロールして [認証] をダブルクリックします。

  4. [認証] ウィンドウで [基本認証] を選択し、[操作] ウィンドウの [有効にする] をクリックします。

  5. [認証] ウィンドウで [匿名認証] を選択し、[操作] ウィンドウの [無効にする] をクリックします。

    拡大

SSL (Secure Sockets Layer) を要求する方法

  1. タスク バーの [スタート] ボタンをクリックして、[管理ツール] をポイントし、[インターネット インフォメーション サービス (IIS) マネージャー] をクリックします。

  2. [接続] ウィンドウで、SSL の要求を構成するサイト、アプリケーション、またはディレクトリに移動します。サーバー レベルで SSL を構成することはできません。

  3. [ホーム] ウィンドウで [SSL 設定] をダブルクリックします。

    拡大

  4. [SSL 設定] ウィンドウで [SSL が必要] をクリックします。

  5. [操作] ウィンドウの [適用] をクリックします。

Web サイト、Web アプリケーション、または Web サービスで Windows 認証を有効にする方法

  1. タスク バーの [スタート] ボタンをクリックして、[管理ツール] をポイントし、[インターネット インフォメーション サービス (IIS) マネージャー] をクリックします。

  2. [接続] ウィンドウで当該サーバー名を展開して [サイト] を展開し、Windows 認証を有効にする Web サイト、Web アプリケーション、または Web サービスをクリックします。

  3. [ホーム] ウィンドウで、[セキュリティ] セクションまでスクロールして [認証] をダブルクリックします。

  4. [認証] ウィンドウで [Windows 認証] を選択し、[操作] ウィンドウの [有効にする] をクリックします。

    拡大

構成

セキュリティ設定を構成する場合、構成 XML に <security> セクション グループを含める必要があります。サーバー レベルでのセキュリティ設定の構成は ApplicationHost.config ファイルに設定します。サイト、アプリケーション、またはディレクトリのレベルでの構成は、該当する Web.config ファイルに設定します。

属性

なし。

子要素

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

認証にクライアント証明書を使用するかどうか、暗号の強さなど、SSL (Secure Sockets Layer) の構成設定を指定します。
applicationDependencies オプションの要素。

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

認証関連の設定を指定します。
authorization オプションの要素。

承認関連の設定を指定します。
ipSecurity オプションの要素。

IP バージョン 4 のアドレスまたは DNS のドメイン名に基づいたアクセス制限を指定します。
isapiCgiRestriction オプションの要素。

サーバー上での実行が許可される CGI および ISAPI プログラムを制限する設定を指定します。
requestFiltering オプションの要素。

要求のフィルタリングの構成設定を指定します。

構成サンプル

次の例では、Contoso という名前の Web サイトの認証、SSL、および要求のフィルタリングの設定を構成します。

<location path="Contoso">
   <system.webServer>
      <security>

         <authentication>
            <windowsAuthentication enabled="true" />
            <basicAuthentication enabled="false" />
            <anonymousAuthentication enabled="false" />
         </authentication>
         <access sslFlags="Ssl, SslNegotiateCert, Ssl128" />

         <requestFiltering>
            <fileExtensions>
               <add fileExtension=".inc" allowed="false" />
            </fileExtensions>
            <denyUrlSequences>
               <add sequence="_vti_bin" />

               <add sequence="_vti_cnf" />
               <add sequence="_vti_pvt" />
            </denyUrlSequences>
         </requestFiltering>
      </security>
   </system.webServer>

</location>

サンプル コード

次の例では、Contoso という名前のサイトで匿名認証を無効にし、基本認証および Windows 認証の両方を有効にします。

AppCmd.exe

appcmd.exe set config "Contoso" -section:system.webServer/security/authentication/anonymousAuthentication /enabled:"False" /commit:apphost

appcmd.exe set config "Contoso" -section:system.webServer/security/authentication/basicAuthentication /enabled:"True" /commit:apphost

appcmd.exe set config "Contoso" -section:system.webServer/security/authentication/windowsAuthentication /enabled:"True" /commit:apphost

: AppCmd.exe を使用してこれらの設定を構成する際には、commit パラメーターを apphost に設定する必要があります。それにより、ApplicationHost.config ファイル内の該当する location セクションに構成設定が適用されます。

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 anonymousAuthenticationSection = config.GetSection("system.webServer/security/authentication/anonymousAuthentication", "Contoso");
         anonymousAuthenticationSection["enabled"] = false;

         ConfigurationSection basicAuthenticationSection = config.GetSection("system.webServer/security/authentication/basicAuthentication", "Contoso");
         basicAuthenticationSection["enabled"] = true;

         ConfigurationSection windowsAuthenticationSection = config.GetSection("system.webServer/security/authentication/windowsAuthentication", "Contoso");
         windowsAuthenticationSection["enabled"] = true;

         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 anonymousAuthenticationSection As ConfigurationSection = config.GetSection("system.webServer/security/authentication/anonymousAuthentication", "Contoso")
      anonymousAuthenticationSection("enabled") = False

      Dim basicAuthenticationSection As ConfigurationSection = config.GetSection("system.webServer/security/authentication/basicAuthentication", "Contoso")
      basicAuthenticationSection("enabled") = True

      Dim windowsAuthenticationSection As ConfigurationSection = config.GetSection("system.webServer/security/authentication/windowsAuthentication", "Contoso")
      windowsAuthenticationSection("enabled") = True

      serverManager.CommitChanges()
   End Sub
End Module

JavaScript

var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST";

var anonymousAuthenticationSection = adminManager.GetAdminSection("system.webServer/security/authentication/anonymousAuthentication", "MACHINE/WEBROOT/APPHOST/Contoso");
anonymousAuthenticationSection.Properties.Item("enabled").Value = false;

var basicAuthenticationSection = adminManager.GetAdminSection("system.webServer/security/authentication/basicAuthentication", "MACHINE/WEBROOT/APPHOST/Contoso");
basicAuthenticationSection.Properties.Item("enabled").Value = true;

var windowsAuthenticationSection = adminManager.GetAdminSection("system.webServer/security/authentication/windowsAuthentication", "MACHINE/WEBROOT/APPHOST/Contoso");
windowsAuthenticationSection.Properties.Item("enabled").Value = true;

adminManager.CommitChanges();

VBScript

Set adminManager = CreateObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"

Set anonymousAuthenticationSection = adminManager.GetAdminSection("system.webServer/security/authentication/anonymousAuthentication", "MACHINE/WEBROOT/APPHOST/Contoso")
anonymousAuthenticationSection.Properties.Item("enabled").Value = False

Set basicAuthenticationSection = adminManager.GetAdminSection("system.webServer/security/authentication/basicAuthentication", "MACHINE/WEBROOT/APPHOST/Contoso")
basicAuthenticationSection.Properties.Item("enabled").Value = True

Set windowsAuthenticationSection = adminManager.GetAdminSection("system.webServer/security/authentication/windowsAuthentication", "MACHINE/WEBROOT/APPHOST/Contoso")
windowsAuthenticationSection.Properties.Item("enabled").Value = True

adminManager.CommitChanges()