管理認証プロバイダー <providers>

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

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

概要

<authentication> 要素の <providers> 要素は、IIS マネージャーを使用してリモートでサイトやアプリケーションに接続するユーザーを認証するために管理サービス (WMSVC) が使用する認証プロバイダーを指定します。

: 既定の認証プロバイダーである ConfigurationAuthenticationProvider は、IIS の Administration.config ファイルを使用して、IIS マネージャーのユーザー資格情報を格納します。

互換性

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

セットアップ

IIS 7.0 の既定のインストールには、"管理サービス" 役割サービスは含まれません。この役割サービスをインストールするには、次の手順を実行します。

Windows Server 2008

  1. タスク バーの [スタート] ボタンをクリックし、[管理ツール] をポイントして [サーバー マネージャー] をクリックします。

  2. [サーバー マネージャー] のツリー表示で、[役割] を展開して [Web サーバー (IIS)] をクリックします。

  3. [Web サーバー (IIS)] ウィンドウで、[役割サービス] セクションまでスクロールして [役割サービスの追加] をクリックします。

  4. 役割サービスの追加ウィザードの [役割サービスの選択] ページで、[管理サービス] を選択して、[次へ] をクリックします。

    拡大

  5. [インストール オプションの確認] ページで [インストール] をクリックします。

  6. [結果] ページで [閉じる] をクリックします。

Windows Vista

  1. タスク バーの [スタート] ボタンをクリックし、[コントロール パネル] をクリックします。

  2. [コントロール パネル][プログラムと機能] をクリックして、[Windows の機能の有効化または無効化] をクリックします。

  3. [Internet Information Services][Web 管理ツール] の順に展開します。

  4. [IIS 管理サービス] を選択して、[OK] をクリックします。

    拡大

方法

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

構成

属性

なし。

子要素

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

認証プロバイダーのコレクションにプロバイダーを追加します。

構成サンプル

次の <authentication> 要素の下の既定の <providers> 要素は、"管理サービス" 役割サービスをインストールすると、IIS 7.0 の Administration.config ファイルに構成されます。

<authentication defaultProvider="ConfigurationAuthenticationProvider">

   <providers>
      <add name="ConfigurationAuthenticationProvider"
         type="Microsoft.Web.Management.Server.ConfigurationAuthenticationProvider, Microsoft.Web.Management, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
   </providers>
</authentication>

サンプル コード

: ここでは、.NET グローバル アセンブリ キャッシュ (GAC) に保存されているマネージ コード アセンブリを使用した例を紹介しています。これらの例で示すコードを使用して独自のアセンブリを展開するには、事前に GAC からアセンブリ情報を取得する必要があります。それには、次の手順を実行します。

  • Windows エクスプローラーで C:\Windows\assembly パスを開きます。C: は使用しているオペレーティング システムのドライブに置き換えてください。
  • アセンブリを見つけます。
  • アセンブリを右クリックして [プロパティ] をクリックします。
  • [カルチャ] の値をコピーします (例 : Neutral)。
  • [バージョン] の番号をコピーします (例 : 1.0.0.0)。
  • [公開キー トークン] の値をコピーします (例 : f0e1d2c3b4a59687)。
  • [キャンセル] をクリックします。

次のコード例では、ContosoAuthenticationProvider という名前の認証プロバイダーを管理認証プロバイダーのコレクションに追加し、既定の認証プロバイダーを ContosoAuthenticationProvider に設定します。

AppCmd.exe

: AppCmd.exe を使用して <system.webServer/Management> の設定を構成することはできません。

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.GetAdministrationConfiguration();

         ConfigurationSection authenticationSection = config.GetSection("system.webServer/management/authentication");
         ConfigurationElementCollection providersCollection = authenticationSection.GetCollection("providers");
         ConfigurationElement addElement = providersCollection.CreateElement("add");
         addElement["name"] = @"ContosoAuthenticationProvider";
         addElement["type"] = @"Contoso.Provider, System.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0e1d2c3b4a59687";
         providersCollection.Add(addElement);
         authenticationSection["defaultProvider"] = "ContosoAuthenticationProvider";

         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.GetAdministrationConfiguration

      Dim authenticationSection As ConfigurationSection = config.GetSection("system.webServer/management/authentication")
      Dim providersCollection As ConfigurationElementCollection = authenticationSection.GetCollection("providers")
      Dim addElement As ConfigurationElement = providersCollection.CreateElement("add")
      addElement("name") = "ContosoAuthenticationProvider"
      addElement("type") = "Contoso.Provider, System.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0e1d2c3b4a59687"
      providersCollection.Add(addElement)
      authenticationSection("defaultProvider") = "ContosoAuthenticationProvider"

      serverManager.CommitChanges()
   End Sub

End Module

JavaScript

var adminManager = new ActiveXObject("Microsoft.ApplicationHost.WritableAdminManager"); 
adminManager.CommitPath = "MACHINE/WEBROOT"; 
adminManager.SetMetadata("pathMapper", "AdministrationConfig");

var authenticationSection = adminManager.GetAdminSection("system.webServer/management/authentication", "MACHINE/WEBROOT"); 
var providersCollection = authenticationSection.ChildElements.Item("providers").Collection;

var addElement = providersCollection.CreateNewElement("add");
addElement.Properties.Item("name").Value = "ContosoAuthenticationProvider";
addElement.Properties.Item("type").Value = "Contoso.Provider, System.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0e1d2c3b4a59687";
providersCollection.AddElement(addElement);
authenticationSection.Properties.Item("defaultProvider").Value = "ContosoAuthenticationProvider";

adminManager.CommitChanges();

VBScript

Set adminManager = WScript.CreateObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT"
adminManager.SetMetadata "pathMapper", "AdministrationConfig"

Set authenticationSection = adminManager.GetAdminSection("system.webServer/management/authentication", "MACHINE/WEBROOT")
Set providersCollection = authenticationSection.ChildElements.Item("providers").Collection

Set addElement = providersCollection.CreateNewElement("add")
addElement.Properties.Item("name").Value = "ContosoAuthenticationProvider"
addElement.Properties.Item("type").Value = "Contoso.Provider, System.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0e1d2c3b4a59687"
providersCollection.AddElement(addElement)
authenticationSection.Properties.Item("defaultProvider").Value = "ContosoAuthenticationProvider"

adminManager.CommitChanges()