構成リダイレクト <configurationRedirection>

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

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

概要

<configurationRedirection> 要素を使用すると、中央の 1 か所にある構成ファイルを Web ファーム内の複数のインターネット インフォメーション サービス (IIS) 7.0 サーバー コンピューターで共有することができます。これにより、Web ファーム内の 1 つの IIS 7.0 サーバーを構成して、その構成設定を同じ Web ファーム内のすべての IIS 7.0 サーバーで共有することが可能になります。また、この要素を使用して UNC サーバーに構成設定を保存し、Web ファーム内のすべての Web サーバー コンピューターがアクセスできるようにすることも可能です。

互換性

  IIS 7.0 IIS 6.0
注意 <configurationRedirection> は IIS 7.0 で新たに導入された要素です。

なし

セットアップ

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

方法

構成設定をエクスポートして共有構成を有効にする方法

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

  2. [接続] ウィンドウで、構成リダイレクトを設定するサーバー接続をクリックします。

  3. [ホーム] ウィンドウで [共有構成] をダブルクリックします。

    拡大

  4. [操作] ウィンドウで [構成のエクスポート] をクリックします。

    拡大

  5. [構成のエクスポート] ダイアログ ボックスで、[物理パス] ボックスに構成ファイルをエクスポートするディレクトリへのパスを入力し、暗号化のパスワードを入力してから再度確認入力を行い、[OK] をクリックします。

    拡大

  6. エクスポートの完了を知らせるメッセージボックスが表示されたら [OK] をクリックします。

    拡大

共有構成を有効にする方法

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

  2. [接続] ウィンドウで、構成リダイレクトを設定するサーバー接続をクリックします。

  3. [ホーム] ウィンドウで [共有構成] をダブルクリックします。

    拡大

  4. [共有構成] ウィンドウで、[共有構成の有効化] オプションを選択します。

  5. [物理パス] ボックスに共有構成ファイルへのパスを入力し、[ユーザー名] ボックスに共有構成ファイルへのアクセス許可を持つアカウント名を入力し、[パスワード] ボックスにアカウントのパスワードを入力して、[パスワードの確認] ボックスに再度アカウントのパスワードを入力します。

    拡大

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

  7. [暗号化キー パスワード] ダイアログ ボックスの [暗号化キー パスワードを入力してください] ボックスに、手順 5 で作成した暗号化キーのパスワードを入力し、[OK] をクリックします。

    拡大

  8. 表示される各 [共有構成] ダイアログ ボックスで [OK] をクリックしてダイアログを閉じます。

    拡大

    拡大

    : これらの構成変更を反映するには、IIS マネージャーを一度閉じてから再起動する必要があります。

構成

<configurationRedirection> 要素は Redirection.config ファイルで構成できます。

属性

属性 説明
enabled オプションの Boolean 属性。

構成リダイレクトを Web サーバーで有効にするかどうかを指定します。

既定値は false です。
password オプションの string 属性。

構成ファイルの保存場所にアクセスするためのユーザー名の認証に必要なパスワードを指定します。パスワードでは大文字と小文字が区別されます。

注 : 暗号化されていないパスワード文字列が構成ファイルに保存されないようにするため、必ず AppCmd.exe または IIS マネージャーを使用してパスワードを入力してください。これらの管理ツールを使用した場合、パスワード文字列は、自動的に暗号化されてから XML 構成ファイルに書き込まれます。そのため、暗号化されていないパスワードを保存するより、パスワードのセキュリティが強化されます。
path オプションの string 属性。

構成ファイルと暗号化キーの読み取り元の場所を指定します。ネットワーク パスまたはローカル コンピューター上のフォルダーを指定できます。
userName オプションの string 属性。

構成ファイルの保存場所にアクセスするためのユーザー名を指定します。

子要素

なし。

構成サンプル

次のコード例では、IIS 7.0 を構成して構成ファイルと暗号化キーをネットワーク上の共有ディレクトリで共有する方法を示します。

<configuration>

   <configSections>
      <section name="configurationRedirection" />
   </configSections>

   <configProtectedData>
      <providers>
         <add name="IISRsaProvider"
            type=""
            description="Uses RsaCryptoServiceProvider to encrypt and decrypt"
            keyContainerName="iisConfigurationKey"
            cspProviderName=""
            useMachineContainer="true"
            useOAEP="false" />
      </providers>
   </configProtectedData>

   <configurationRedirection enabled="true"
      path="\\ServerName\ShareName"
      userName="MyUser"
      password="[enc:IISRsaProvider:Encrypted-Password-Data:enc]" />

</configuration>

サンプル コード

次の例では、\\SeverName\ShareName で共有されているエクスポートされた構成ファイルを使用して共有構成を有効にできます。このとき、ユーザー名には「MyUser」、パスワードには「P@ssw0rd」を使用して共有ファイルにアクセスします。

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.GetRedirectionConfiguration();
         ConfigurationSection redirectionSection = config.GetSection("configurationRedirection");

         redirectionSection.Attributes["enabled"].Value = true;
         redirectionSection.Attributes["path"].Value = @"\\SeverName\ShareName";
         redirectionSection.Attributes["userName"].Value = @"MyUser";
         redirectionSection.Attributes["password"].Value = @"P@ssw0rd";

         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.GetRedirectionConfiguration
      Dim redirectionSection As ConfigurationSection = config.GetSection("configurationRedirection")
      redirectionSection.Attributes("enabled").Value = True
      redirectionSection.Attributes("path").Value = "\\SeverName\ShareName"
      redirectionSection.Attributes("userName").Value = "MyUser"
      redirectionSection.Attributes("password").Value = "P@ssw0rd"
      serverManager.CommitChanges()
   End Sub
End Module

JavaScript

try
{
   var config = WScript.CreateObject( "Microsoft.ApplicationHost.WritableAdminManager" );
   config.CommitPath = "MACHINE/REDIRECTION";
   var section = config.GetAdminSection( "configurationRedirection","MACHINE/REDIRECTION" );
   section.Properties.Item( "enabled" ).Value = true;
   section.Properties.Item( "path" ).Value = "\\\\SeverName\\ShareName";
   section.Properties.Item( "userName" ).Value = "MyUser";
   section.Properties.Item( "password" ).Value = "P@ssw0rd";
   config.CommitChanges();
}
catch(e)
{
   WScript.Echo(e.number); 
   WScript.Echo(e.description);
}

VBScript

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

Set configurationRedirection = adminManager.GetAdminSection( "configurationRedirection", _
"MACHINE/REDIRECTION" )

configurationRedirection.Properties.Item( "enabled" ).Value = True
configurationRedirection.Properties.Item( "path" ).Value = "\\SeverName\ShareName"
configurationRedirection.Properties.Item( "userName" ).Value = "MyUser"
configurationRedirection.Properties.Item( "password" ).Value = "P@ssw0rd"

adminManager.CommitChanges