セキュリティ認証 <authentication>

概要

認証は、Web サイトまたは Web アプリケーションへの訪問者の身元を確認するために使用するメカニズムです。 通常、ユーザー名とパスワードを訪問者に割り当てるか、訪問者がサイト上のパブリック コンテンツに匿名でアクセスできるようにすることで、これを行います。

認証を使用して訪問者の身元を確認しますが、承認を使用して、サイトまたはアプリケーションのさまざまな領域への訪問者のアクセスを制御します。

IIS 7 では、匿名認証、基本認証、クライアント証明書マッピング認証、ダイジェスト認証、IIS クライアント証明書マッピング認証、Windows 認証がサポートされています。 サード パーティの認証モジュールでは、追加の認証モードが提供される場合があります。

認証モジュールの 1 つをインストールしたら、それを使用する Web サイト、Web アプリケーション、または Web サービスに対して選択した認証モジュールを有効にする必要があります。

また、既定では、IIS 7 では Windows (Kerberos または NTLM を使用) 認証スキームのカーネル モード認証が有効になります。 カーネル モード認証には、次の利点があります。

  • Web アプリケーションは、低い特権のアカウントを使用して実行できます。
  • Kerberos 認証を使用する場合は、サーバーのサービス プリンシパル名 (SPN) に関連付けられている既定のアカウントとは異なるアカウントを使用できます。
  • カーネル モード認証を使用する場合は、明示的な SPN 構成を実行せずに Windows 認証 Kerberos プロバイダーを使用できます。

互換性

バージョン メモ
IIS 10.0 <authentication> 要素は、IIS 10.0 では変更されませんでした。
IIS 8.5 <authentication> 要素は、IIS 8.5 では変更されませんでした。
IIS 8.0 <authentication> 要素は IIS 8.0 では変更されませんでした。
IIS 7.5 <authentication> 要素は、IIS 7.5 では変更されませんでした。
IIS 7.0 <authentication> 要素が IIS 7.0 で導入されました。
IIS 6.0 該当なし

段取り

<authentication> 要素が IIS 7 の既定のインストールに含められます。

操作方法

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

  1. インターネット インフォメーション サービス (IIS) マネージャーを開きます。

    • Windows Server 2012 または Windows Server 2012 R2 を使用している場合:

      • タスク バーで、[サーバー マネージャー] をクリックし、[ツール][インターネット インフォメーション サービス (IIS) マネージャー] の順にクリックします。
    • Windows 8 または Windows 8.1 を使用している場合:

      • Windows キーを押しながら文字 X を押し、[コントロール パネル] をクリックします。
      • [管理ツール] をクリックし、[インターネット インフォメーション サービス (IIS) マネージャー] をダブルクリックします。
    • Windows Server 2008 または Windows Server 2008 R2 を使用している場合:

      • タスク バーで、[スタート] ボタンをクリックし、[管理ツール][インターネット インフォメーション サービス (IIS) マネージャー] の順にクリックします。
    • Windows Vista または Windows 7 を使用している場合:

      • タスク バーで、[スタート][コントロール パネル] の順にクリックします。
      • [管理ツール] をダブルクリックし、[インターネット インフォメーション サービス (IIS) マネージャー] をダブルクリックします。
  2. [接続] ウィンドウで、サーバー名を展開し、[サイト] を展開し、構成する階層ウィンドウのレベルに移動し、Web サイトまたは Web アプリケーションをクリックします。

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

  4. [認証] ウィンドウで [匿名認証] を選択し、[操作] ウィンドウで [無効] をクリックします。
    Screenshot that shows the Authentication pane. Anonymous Authentication is enabled and selected.

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

  1. インターネット インフォメーション サービス (IIS) マネージャーを開きます。

    • Windows Server 2012 または Windows Server 2012 R2 を使用している場合:

      • タスク バーで、[サーバー マネージャー] をクリックし、[ツール][インターネット インフォメーション サービス (IIS) マネージャー] の順にクリックします。
    • Windows 8 または Windows 8.1 を使用している場合:

      • Windows キーを押しながら文字 X を押し、[コントロール パネル] をクリックします。
      • [管理ツール] をクリックし、[インターネット インフォメーション サービス (IIS) マネージャー] をダブルクリックします。
    • Windows Server 2008 または Windows Server 2008 R2 を使用している場合:

      • タスク バーで、[スタート] ボタンをクリックし、[管理ツール][インターネット インフォメーション サービス (IIS) マネージャー] の順にクリックします。
    • Windows Vista または Windows 7 を使用している場合:

      • タスク バーで、[スタート][コントロール パネル] の順にクリックします。
      • [管理ツール] をダブルクリックし、[インターネット インフォメーション サービス (IIS) マネージャー] をダブルクリックします。
  2. [接続] ウィンドウで、サーバー名を展開し、[サイト] を展開し、構成する階層ウィンドウのレベルに移動し、Web サイトまたは Web アプリケーションをクリックします。

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

  4. [認証] ウィンドウで [匿名認証] を選択し、[操作] ウィンドウで [編集...] をクリックします。

  5. [匿名認証資格情報の編集] ダイアログ ボックスで、次のいずれかを実行します。

    • アプリケーション プールの ID セットを使用するアプリケーション プール ID を選択し、[OK] をクリックします。
      Screenshot that shows the Edit Anonymous Authentication Credentials dialog box. Application pool identity is selected.

    • [設定...] をクリックし、[資格情報の設定] ダイアログ ボックスの [ユーザー名] ボックスにアカウントのユーザー名を入力し、[パスワード] ボックスと [パスワードの確認] ボックスにアカウントのパスワードを入力し、[OK] をクリックして、もう一度 [OK] をクリックします。
      Screenshot that shows the Set Credentials dialog box.

      Note

      この手順を使用する場合は、IIS サーバー コンピューターで新しいアカウントに最小限の特権のみを付与します。


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

  1. インターネット インフォメーション サービス (IIS) マネージャーを開きます。

    • Windows Server 2012 または Windows Server 2012 R2 を使用している場合:

      • タスク バーで、[サーバー マネージャー] をクリックし、[ツール][インターネット インフォメーション サービス (IIS) マネージャー] の順にクリックします。
    • Windows 8 または Windows 8.1 を使用している場合:

      • Windows キーを押しながら文字 X を押し、[コントロール パネル] をクリックします。
      • [管理ツール] をクリックし、[インターネット インフォメーション サービス (IIS) マネージャー] をダブルクリックします。
    • Windows Server 2008 または Windows Server 2008 R2 を使用している場合:

      • タスク バーで、[スタート] ボタンをクリックし、[管理ツール][インターネット インフォメーション サービス (IIS) マネージャー] の順にクリックします。
    • Windows Vista または Windows 7 を使用している場合:

      • タスク バーで、[スタート][コントロール パネル] の順にクリックします。
      • [管理ツール] をダブルクリックし、[インターネット インフォメーション サービス (IIS) マネージャー] をダブルクリックします。
  2. [接続] ウィンドウで、サーバー名を展開し、[サイト] を展開し、Windows 認証を有効にするサイト、アプリケーション、または Web サービスをクリックします。

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

  4. [認証] ウィンドウで [Windows 認証] を選択し、[操作] ウィンドウで [有効] をクリックします。
    Screenshot that shows the Authentication pane. Windows Authentication is disabled and selected.

構成

<authentication> セクション グループは、<system.webServer> 構成セクションで定義されています。 このセクション グループでは、サーバーにインストールして有効にできるすべてのユーザー認証の種類の構成セクションを定義します。 これは、ApplicationHost.config ファイルのサーバー レベルと Web.config ファイルのアプリケーション レベルで構成できます。

属性

なし。

子要素

要素 説明
anonymousAuthentication 省略可能な要素です。

匿名認証の設定を指定します。
basicAuthentication 省略可能な要素です。

基本認証の設定を指定します。
clientCertificateMappingAuthentication 省略可能な要素です。

Active Directory を使用したクライアント証明書マッピング認証の設定を指定します。
digestAuthentication 省略可能な要素です。

ダイジェスト認証の設定を指定します。
iisClientCertificateMappingAuthentication 省略可能な要素です。

IIS を使用したクライアント証明書マッピング認証の設定を指定します。
windowsAuthentication 省略可能な要素です。

Windows 認証の設定を指定します。

構成サンプル

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

<location path="Contoso">
   <system.webServer>
      <security>
         <authentication>
            <anonymousAuthentication enabled="false" />
            <basicAuthentication enabled="true" defaultLogonDomain="Contoso" />
            <windowsAuthentication enabled="true" />
          </authentication>
      </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

Note

AppCmd.exe を使用してこれらの設定を構成する場合は、commit パラメーターを必ず apphost に設定する必要があります。 これにより、ApplicationHost.config ファイルの適切な場所セクションに構成設定がコミットされます。

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()