次の方法で共有


多対一マッピングの追加 <add>

概要

<manyToOneMappings> 要素の <add> 要素は、一意のクライアント証明書マッピングを多対一マッピングのコレクションに追加します。

多対一マッピングは、それぞれがユーザー アカウントとパスワードにマップされます。これは、Windows 認証基本認証など、より一般的に使用される認証方法の代わりに使用できます。

多対一ルールに対して有効にできるアクセス方法には、許可拒否の 2 種類があります。 これらの設定を使用すると、サイトへのアクセスを許可するクライアント証明書のグループを受け入れながら、別の条件に基づいて他の証明書グループのアクセスを拒否するルールを作成できます。 たとえば、人事組織単位内のすべての Contoso 従業員のアクセスを許可しながら、営業組織単位の従業員のアクセスを拒否するルールを作成できます。

Note

多対一の証明書マッピングは、個々のクライアント証明書を個々のユーザー アカウントにマップする一対一の証明書マッピングとは異なります。

互換性

バージョン メモ
IIS 10.0 <add> 要素は IIS 10.0 では変更されませんでした。
IIS 8.5 <add> 要素は IIS 8.5 では変更されませんでした。
IIS 8.0 <add> 要素は IIS 8.0 では変更されませんでした。
IIS 7.5 <add> 要素は IIS 7.5 では変更されませんでした。
IIS 7.0 <manyToOneMappings> 要素の <add> 要素が IIS 7.0 で導入されました。
IIS 6.0 <manyToOneMappings> 要素は、IIS 6.0 IIsCertMapper メタベース オブジェクトを置き換えます。

段取り

<iisClientCertificateMappingAuthentication> 要素は、IIS 7 以降の既定のインストールでは使用できません。 インストールするには、次の手順を使用します。

Windows Server 2012 または Windows Server 2012 R2

  1. タスク バーで [サーバー マネージャー]をクリックします。
  2. [サーバー マネージャー] で、[管理] メニューを選択し、[役割と機能の追加] を選択します。
  3. [役割と機能の追加] ウィザードで、[次へ] をクリックします。 インストールの種類を選択し、[次へ] をクリックします。 対象サーバーを選択し、[次へ] をクリックします。
  4. [サーバー ロール] ページで、[Web サーバー (IIS)][Web サーバー] の順に展開し、[セキュリティ] を展開して、[IIS クライアント証明書マッピング認証] を選択します。 次へ をクリックします。
    [Web サーバーとセキュリティ] ウィンドウが展開され、[I S クライアント証明書マッピング認証] が選択されている画像。 .
  5. [機能の選択] ページで、[次へ] をクリックします。
  6. [インストール オプションの確認] ページで、[インストール] をクリックします。
  7. [結果] ページで、 [閉じる]をクリックします。

Windows 8 または Windows 8.1

  1. [スタート] 画面で、ポインターを左下隅まで移動し、[スタート] ボタンを右クリックし、[コントロール パネル] をクリックします。
  2. [コントロール パネル][プログラムと機能] をクリックし、[Windows の機能の有効化または無効化] をクリックします。
  3. [インターネット インフォメーション サービス] を展開し、[World Wide Web サービス] を展開し、[セキュリティ] を展開して、[IIS クライアント証明書マッピング認証] を選択します。
    [World Wide Web Services and Security]\(World Wide Web サービスとセキュリティ\) ウィンドウが展開され、[I I S Client Certificate Mapping Authentication]\(I I S クライアント証明書マッピング認証\) が選択されているスクリーンショット。
  4. OK をクリックします。
  5. 閉じるをクリックします。

Windows Server 2008 または Windows Server 2008 R2

  1. タスク バーで [スタート] をクリックし、[管理ツール] をポイントして、[サーバー マネージャ] をクリックします。
  2. [サーバー マネージャ] 階層ウィンドウで [役割] を展開し、[Web サーバー (IIS)] をクリックします。
  3. [Web Server (IIS)] (Web サーバー (IIS)) ウィンドウで、[Role Services] (役割サービス) セクションまでスクロールし、[Add Role Services] (役割サービスの追加) をクリックします。
  4. 役割サービスの追加ウィザード[役割サービスの選択] ページで、[IIS クライアント証明書マッピング認証] を選択し、[次へ] をクリックします。
    I I S クライアント証明書マッピング認証が選択されている [役割サービスの選択] ページの画像。
  5. [インストール オプションの確認] ページで、[インストール] をクリックします。
  6. [結果] ページで、 [閉じる]をクリックします。

Windows Vista または Windows 7

  1. タスク バーで、[スタート][コントロール パネル] の順にクリックします。
  2. [コントロール パネル][プログラムと機能] をクリックし、[Turn Windows Features on or off] (Windows の機能の有効化または無効化) をクリックします。
  3. [インターネット インフォメーション サービス] を展開し、[IIS クライアント証明書マッピング認証] を選択し、[OK] をクリックします。
    [インターネット インフォメーション サービス ペインが展開され、I I S クライアント証明書マッピング認証が強調表示されているスクリーンショット。

操作方法

IIS 7 の IIS クライアント証明書マッピング認証を構成するためのユーザー インターフェイスはありません。 IIS クライアント証明書マッピング認証をプログラムで構成する方法の例については、このドキュメントの「コード サンプル」セクションを参照してください。

構成

属性

属性 説明
説明 省略可能な文字列属性。

この一対多マッピングの説明を指定します。
enabled 省略可能な Boolean 属性です。

この一対多マッピングを有効にするかどうかを指定します。

既定値は true です。
name 必須の文字列属性です。

この一対多マッピングの名前を指定します。
password 省略可能な文字列属性。

この規則に一致するクライアントの認証に使用するアカウントのパスワードを指定します。

注: 暗号化されていないパスワード文字列を構成ファイルに格納しないようにするには、常に AppCmd.exe または IIS マネージャーを使用してパスワードを入力してください。 これらの管理ツールを使用する場合、パスワード文字列は XML 構成ファイルに書き込まれる前に自動的に暗号化されます。 これにより、暗号化されていないパスワードを格納するよりも、パスワードのセキュリティが向上します。
permissionMode 省略可能な列挙型属性。

permissionMode 属性には、次のいずれかの値を指定できます。 既定値は、Allow です。
Value 説明
Allow 一致するクライアント証明書を持つクライアントに認証のアクセス許可を付与することを指定します。

数値は 1 です。
Deny 一致するクライアント証明書を持つクライアントに対する認証のアクセス許可を拒否することを指定します。

数値は 2 です。
username 省略可能な文字列属性。

この規則に一致するクライアントの認証に使用するアカウントのユーザー名を指定します。

子要素

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

多くのクライアントが 1 つの証明書を使用できるように、クライアント証明書を IIS にマッピングするための条件を指定します。

構成サンプル

次の構成サンプルでは、既定の Web サイトに対して次の操作を実行します。

  • 多対一の証明書マッピングを使用して IIS クライアント証明書マッピング認証を有効にします。
  • Contoso と一致するクライアント証明書のサブジェクトの組織フィールドに基づいて、ユーザー アカウントの多対一の証明書マッピング規則を作成します。
  • SSL を要求し、クライアント証明書をネゴシエートするようにサイトを構成します。
<location path="Default Web Site">
   <system.webServer>
      <security>
         <authentication>
            <windowsAuthentication enabled="false" />
            <anonymousAuthentication enabled="false" />
            <digestAuthentication enabled="false" />
            <basicAuthentication enabled="false" />
            <iisClientCertificateMappingAuthentication enabled="true"
                  manyToOneCertificateMappingsEnabled="true">
               <manyToOneMappings>
                  <add name="Contoso Employees"
                        enabled="true"
                        permissionMode="Allow"
                        userName="Username"
                        password="[enc:AesProvider:57686f6120447564652c2049495320526f636b73:enc]">
                     <rules>
                        <add certificateField="Subject"
                           certificateSubField="O"
                           matchCriteria="Contoso"
                           compareCaseSensitive="true" />
                     </rules>
                  </add>
               </manyToOneMappings>
            </iisClientCertificateMappingAuthentication>
         </authentication>
         <access sslFlags="Ssl, SslNegotiateCert" />
      </security>
   </system.webServer>
</location>

サンプル コード

次のコード サンプルでは、既定の Web サイトに対して次の操作を実行します。

  • 多対一の証明書マッピングを使用して IIS クライアント証明書マッピング認証を有効にします。
  • Contoso と一致するクライアント証明書のサブジェクトの組織フィールドに基づいて、ユーザー アカウントに多対一の証明書マッピング規則を作成します。
  • SSL を要求し、クライアント証明書をネゴシエートするようにサイトを構成します。

AppCmd.exe

appcmd.exe set config "Default Web Site" -section:system.webServer/security/authentication/iisClientCertificateMappingAuthentication /enabled:"True" /manyToOneCertificateMappingsEnabled:"True" /commit:apphost

appcmd.exe set config "Default Web Site" -section:system.webServer/security/authentication/iisClientCertificateMappingAuthentication /+"manyToOneMappings.[name='Contoso Employees',enabled='True',permissionMode='Allow',userName='Username',password='Password']" /commit:apphost

appcmd.exe set config "Default Web Site" -section:system.webServer/security/authentication/iisClientCertificateMappingAuthentication /+"manyToOneMappings.[name='Contoso Employees'].rules.[certificateField='Subject',certificateSubField='O',matchCriteria='Contoso',compareCaseSensitive='True']" /commit:apphost

appcmd.exe set config "Default Web Site" -section:system.webServer/security/access /sslFlags:"Ssl, SslNegotiateCert" /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 iisClientCertificateMappingAuthenticationSection = config.GetSection("system.webServer/security/authentication/iisClientCertificateMappingAuthentication", "Default Web Site");
         iisClientCertificateMappingAuthenticationSection["enabled"] = true;
         iisClientCertificateMappingAuthenticationSection["manyToOneCertificateMappingsEnabled"] = true;

         ConfigurationElementCollection manyToOneMappingsCollection = iisClientCertificateMappingAuthenticationSection.GetCollection("manyToOneMappings");
         ConfigurationElement addElement = manyToOneMappingsCollection.CreateElement("add");
         addElement["name"] = @"Contoso Employees";
         addElement["enabled"] = true;
         addElement["permissionMode"] = @"Allow";
         addElement["userName"] = @"Username";
         addElement["password"] = @"Password";

         ConfigurationElementCollection rulesCollection = addElement.GetCollection("rules");
         ConfigurationElement addElement1 = rulesCollection.CreateElement("add");
         addElement1["certificateField"] = @"Subject";
         addElement1["certificateSubField"] = @"O";
         addElement1["matchCriteria"] = @"Contoso";
         addElement1["compareCaseSensitive"] = true;
         rulesCollection.Add(addElement1);
         manyToOneMappingsCollection.Add(addElement);

         ConfigurationSection accessSection = config.GetSection("system.webServer/security/access", "Default Web Site");
         accessSection["sslFlags"] = @"Ssl, SslNegotiateCert";

         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 iisClientCertificateMappingAuthenticationSection As ConfigurationSection = config.GetSection("system.webServer/security/authentication/iisClientCertificateMappingAuthentication", "Default Web Site")
      iisClientCertificateMappingAuthenticationSection("enabled") = True
      iisClientCertificateMappingAuthenticationSection("manyToOneCertificateMappingsEnabled") = True

      Dim manyToOneMappingsCollection As ConfigurationElementCollection = iisClientCertificateMappingAuthenticationSection.GetCollection("manyToOneMappings")
      Dim addElement As ConfigurationElement = manyToOneMappingsCollection.CreateElement("add")
      addElement("name") = "Contoso Employees"
      addElement("enabled") = True
      addElement("permissionMode") = "Allow"
      addElement("userName") = "Username"
      addElement("password") = "Password"

      Dim rulesCollection As ConfigurationElementCollection = addElement.GetCollection("rules")
      Dim addElement1 As ConfigurationElement = rulesCollection.CreateElement("add")
      addElement1("certificateField") = "Subject"
      addElement1("certificateSubField") = "O"
      addElement1("matchCriteria") = "Contoso"
      addElement1("compareCaseSensitive") = True
      rulesCollection.Add(addElement1)
      manyToOneMappingsCollection.Add(addElement)

      Dim accessSection As ConfigurationSection = config.GetSection("system.webServer/security/access", "Default Web Site")
      accessSection("sslFlags") = "Ssl, SslNegotiateCert"

      serverManager.CommitChanges()
   End Sub

End Module

JavaScript

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

var iisClientCertificateMappingAuthenticationSection = adminManager.GetAdminSection("system.webServer/security/authentication/iisClientCertificateMappingAuthentication", "MACHINE/WEBROOT/APPHOST/Default Web Site");
iisClientCertificateMappingAuthenticationSection.Properties.Item("enabled").Value = true;
iisClientCertificateMappingAuthenticationSection.Properties.Item("manyToOneCertificateMappingsEnabled").Value = true;

var manyToOneMappingsCollection = iisClientCertificateMappingAuthenticationSection.ChildElements.Item("manyToOneMappings").Collection;
var addElement = manyToOneMappingsCollection.CreateNewElement("add");
addElement.Properties.Item("name").Value = "Contoso Employees";
addElement.Properties.Item("enabled").Value = true;
addElement.Properties.Item("permissionMode").Value = "Allow";
addElement.Properties.Item("userName").Value = "Username";
addElement.Properties.Item("password").Value = "Password";

var rulesCollection = addElement.ChildElements.Item("rules").Collection;
var addElement1 = rulesCollection.CreateNewElement("add");
addElement1.Properties.Item("certificateField").Value = "Subject";
addElement1.Properties.Item("certificateSubField").Value = "O";
addElement1.Properties.Item("matchCriteria").Value = "Contoso";
addElement1.Properties.Item("compareCaseSensitive").Value = true;
rulesCollection.AddElement(addElement1);
manyToOneMappingsCollection.AddElement(addElement);

var accessSection = adminManager.GetAdminSection("system.webServer/security/access", "MACHINE/WEBROOT/APPHOST/Default Web Site");
accessSection.Properties.Item("sslFlags").Value = "Ssl, SslNegotiateCert";

adminManager.CommitChanges();

VBScript

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

Set iisClientCertificateMappingAuthenticationSection = adminManager.GetAdminSection("system.webServer/security/authentication/iisClientCertificateMappingAuthentication", "MACHINE/WEBROOT/APPHOST/Default Web Site")
iisClientCertificateMappingAuthenticationSection.Properties.Item("enabled").Value = True
iisClientCertificateMappingAuthenticationSection.Properties.Item("manyToOneCertificateMappingsEnabled").Value = True

Set manyToOneMappingsCollection = iisClientCertificateMappingAuthenticationSection.ChildElements.Item("manyToOneMappings").Collection
Set addElement = manyToOneMappingsCollection.CreateNewElement("add")
addElement.Properties.Item("name").Value = "Contoso Employees"
addElement.Properties.Item("enabled").Value = True
addElement.Properties.Item("permissionMode").Value = "Allow"
addElement.Properties.Item("userName").Value = "Username"
addElement.Properties.Item("password").Value = "Password"

Set rulesCollection = addElement.ChildElements.Item("rules").Collection
Set addElement1 = rulesCollection.CreateNewElement("add")
addElement1.Properties.Item("certificateField").Value = "Subject"
addElement1.Properties.Item("certificateSubField").Value = "O"
addElement1.Properties.Item("matchCriteria").Value = "Contoso"
addElement1.Properties.Item("compareCaseSensitive").Value = True
rulesCollection.AddElement(addElement1)
manyToOneMappingsCollection.AddElement(addElement)

Set accessSection = adminManager.GetAdminSection("system.webServer/security/access", "MACHINE/WEBROOT/APPHOST/Default Web Site")
accessSection.Properties.Item("sslFlags").Value = "Ssl, SslNegotiateCert"

adminManager.CommitChanges()