次の方法で共有


すべてのサイトに対する仮想ディレクトリの既定値 <virtualDirectoryDefaults>

概要

<sites> 要素の <virtualDirectoryDefaults> 要素には、サーバー上のすべての仮想ディレクトリに対して既定の設定を指定します。 <virtualDirectoryDefaults> 要素は、サーバー上のすべての仮想ディレクトリに明示的に定義された属性がないときに、暗黙的に共有する共通の属性を定義するのに便利です。

Note

特定の仮想ディレクトリに対して <virtualDirectoryDefaults> セクションと <virtualDirectory> セクションの両方で同じ属性または子要素が構成されている場合は、<virtualDirectory> セクションの構成がその仮想ディレクトリに対して使用されます。

互換性

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

段取り

<sites> 要素の <virtualDirectoryDefaults> 要素は、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. [接続] ウィンドウでサーバー名を展開し、[サイト] ノードをクリックします。

  3. サーバーの [サイト] ペインで、[操作] ウィンドウの [Web サイトの既定値の設定...] をクリックします。。
    [インターネット インフォメーション サービス マネージャー] ウィンドウを示すスクリーンショット。サイトへの接続が強調表示されます。

  4. [Web サイトの既定値] ダイアログ ボックスで、すべての Web サイトに対して既定の仮想ディレクトリ資格情報を指定し、[OK] をクリックします。
    Web サイトの既定値を示すスクリーンショット。アプリケーション プールが強調表示されています。

構成

属性

属性 説明
allowSubDirConfig 省略可能な Boolean 属性です。

IIS で、Web.config ファイルの検索時に現在のレベルより低いディレクトリ階層のコンテンツ ディレクトリ内も対象にするか (true)、Web.config ファイルの検索時に現在のレベルより低いコンテンツ ディレクトリ内は対象にしないか (false) を指定します。

既定値は true です。
logonMethod 省略可能な列挙型属性。

サーバー上のすべての仮想ディレクトリの既定のログオン方法を指定します。

logonMethod 属性には、次のいずれかの値を指定できます。 既定値は、ClearText です。
Value 説明
Batch このログオンの種類は、ユーザーが直接介入することなく、そのユーザーの代わりにプロセスを実行することがあるバッチ サーバーを対象としています。

数値は 1 です。
ClearText このログオンの種類では、名前とパスワードが認証パッケージ内に保存されます。 これにより、サーバーはクライアントに偽装しながら他のネットワーク サーバーに接続できるようになります。

数値は 3 です。
Interactive このログオンの種類は、コンピューターを対話的に使用するユーザーを対象としています。

数値は 0 です。
Network このログオンの種類は、プレーンテキスト パスワードを認証するハイ パフォーマンス サーバー向けです。 このログオンの種類については、資格情報がキャッシュされません。

数値は 2 です。
これらの値の詳細については、「LogonUser」を参照してください。
password 省略可能な文字列属性。

ユーザー名に関連付けられているパスワードを指定します。

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

サーバー上のすべての仮想ディレクトリに対して既定の仮想パスを指定します。
physicalPath 省略可能な文字列属性。

サーバー上のすべての仮想ディレクトリに対して既定の物理パスを指定します。
userName 省略可能な文字列属性。

サーバー上のすべての仮想ディレクトリに対して構成ファイルとコンテンツにアクセスできるアカウントの既定のユーザー名を指定します。

子要素

なし。

構成サンプル

次の構成サンプルは、サーバー上のすべての仮想ディレクトリに対して既定のログオン方法を指定します。

<sites>
   <virtualDirectoryDefaults logonMethod="Network" />
</sites>

サンプル コード

次のコード サンプルでは、サーバー上のすべての仮想ディレクトリに対して既定のログオン方法を指定します。

AppCmd.exe

appcmd.exe set config -section:system.applicationHost/sites /virtualDirectoryDefaults.logonMethod:"Network" /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 sitesSection = config.GetSection("system.applicationHost/sites");

         ConfigurationElement virtualDirectoryDefaultsElement = sitesSection.GetChildElement("virtualDirectoryDefaults");
         virtualDirectoryDefaultsElement["logonMethod"] = @"Network";

         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 sitesSection As ConfigurationSection = config.GetSection("system.applicationHost/sites")

      Dim virtualDirectoryDefaultsElement As ConfigurationElement = sitesSection.GetChildElement("virtualDirectoryDefaults")
      virtualDirectoryDefaultsElement("logonMethod") = "Network"

      serverManager.CommitChanges()
   End Sub

End Module

JavaScript

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

var sitesSection = adminManager.GetAdminSection("system.applicationHost/sites", "MACHINE/WEBROOT/APPHOST");
var virtualDirectoryDefaultsElement = sitesSection.ChildElements.Item("virtualDirectoryDefaults");
virtualDirectoryDefaultsElement.Properties.Item("logonMethod").Value = "Network";

adminManager.CommitChanges();

VBScript

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

Set sitesSection = adminManager.GetAdminSection("system.applicationHost/sites", "MACHINE/WEBROOT/APPHOST")
Set virtualDirectoryDefaultsElement = sitesSection.ChildElements.Item("virtualDirectoryDefaults")
virtualDirectoryDefaultsElement.Properties.Item("logonMethod").Value = "Network"

adminManager.CommitChanges()