すべてのサイトの仮想ディレクトリの既定値 <virtualDirectoryDefaults>
- 概要
- 互換性
- セットアップ
- 方法
- 構成
- サンプル コード
※本ページに挿入されている画像をクリックすると、画像全体が別ウィンドウで表示されます。
概要
<sites>
要素の <virtualDirectoryDefaults>
要素では、サーバー上のすべての仮想ディレクトリの既定の設定を指定します。<virtualDirectoryDefaults>
要素は、サーバー上のすべての仮想ディレクトリにおいて、明示的に属性を定義していない場合に、暗黙的に共有する共通の属性を定義するのに役立ちます。
注 : 特定の仮想ディレクトリにおいて <virtualDirectoryDefaults>
セクションと <virtualDirectory>
セクションの両方で同じ属性または子要素が構成されている場合、その仮想ディレクトリでは <virtualDirectory>
セクションの構成が使用されます。
互換性
IIS 7.0 | IIS 6.0 | |
---|---|---|
説明 | <sites> の <virtualDirectoryDefaults> は IIS 7.0 で新たに導入された要素です。 |
なし |
セットアップ
<sites>
要素の <virtualDirectoryDefaults>
要素は、IIS 7.0 の既定のインストールに含まれています。
方法
サーバーの既定の仮想ディレクトリ資格情報を構成する方法
タスク バーの [スタート] ボタンをクリックして、[管理ツール] をポイントし、[インターネット インフォメーション サービス (IIS) マネージャー] をクリックします。
[接続] ウィンドウで、対象のサーバー名を展開し、[サイト] をクリックします。
サーバーの [サイト] ウィンドウで、[操作] ウィンドウにある [Web サイトの既定値の設定] をクリックします。
[Web サイトの既定値] ダイアログ ボックスで、すべての Web サイトの既定の仮想ディレクトリ資格情報を指定して、[OK] をクリックします。
構成
属性
属性 | 説明 |
---|---|
allowSubDirConfig |
オプションの Boolean 属性。 True の場合は、IIS は現在のディレクトリ階層より下のコンテンツ ディレクトリで Web.config ファイルを検索し、False の場合は、現在の階層より下のコンテンツ ディレクトリで Web.config ファイルを検索しません。 既定値は true です。 |
logonMethod |
オプションの enum 属性。 サーバー上のすべての仮想ディレクトリに対する既定のログオン方法を指定します。 logonMethode 属性には、次のいずれかの値を指定できます。既定値は ClearText です。--------------------------------------------------------------------------------------------------------- 値: Batch 説明:
値: ClearText 説明:
値: Interactive 説明:
値: Network 説明:
*これらの値の詳細については、MSDN サイトの「LogonUser」(英語) を参照してください。 |
password |
オプションの string 属性。 ユーザー名に関連付けられるパスワードを指定します。 注 : 暗号化されていないパスワード文字列が構成ファイルに保存されないようにするために、必ず AppCmd.exe または IIS マネージャーを使用してパスワードを入力してください。これらの管理ツールを使用すると、パスワード文字列は自動的に暗号化されてから XML 構成ファイルに書き込まれます。そのため、暗号化されていないパスワードを保存するよりも、パスワードのセキュリティが強化されます。 |
path |
オプションの string 属性。 サーバー上のすべての仮想ディレクトリの既定の仮想パスを指定します。 |
physicalPath |
オプションの string 属性。 サーバー上のすべての仮想ディレクトリの既定の物理パスを指定します。 |
userName |
オプションの string 属性。 サーバー上のすべての仮想ディレクトリの構成ファイルとコンテンツにアクセスできる、既定のアカウントのユーザー名を指定します。 |
子要素
なし。
構成サンプル
次の構成サンプルでは、サーバー上のすべての仮想ディレクトリに対する既定のログオン方法を指定します。
<sites>
<virtualDirectoryDefaults logonMethod="Network" />
</sites>
サンプル コード
次のコード サンプルでは、サーバー上のすべての仮想ディレクトリに対する既定のログオン方法を指定します。
AppCmd.exe
appcmd.exe set config -section:system.applicationHost/sites /virtualDirectoryDefaults.logonMethod:"Network" /commit:apphost
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()