概要
<anonymousAuthentication>
要素は、インターネット インフォメーション サービス (IIS) 7 が匿名ユーザーからの要求を処理する方法を制御します。 <anonymousAuthentication>
要素を変更して匿名認証を無効にすることも、カスタム ユーザー アカウントを使用して匿名要求を処理するようにインターネット インフォメーション サービス (IIS) を構成することもできます。
匿名認証では、ユーザー名またはパスワードの入力を求めることなく、Web または FTP サイトのパブリック領域へのアクセス権がユーザーに与えられます。 既定では、IIS 7.0 で導入され、IIS 6.0 IUSR_computername アカウントに置き換えられた IUSR アカウントは、匿名アクセスを許可するために使用されます。 アプリケーションは、HTTP などのプロトコル経由でコンテンツを配信したり、サービスを提供したりする一連のファイルです。 IIS でアプリケーションを作成すると、アプリケーションのパスがサイトの URL の一部になります。
既定では、IIS 7 では匿名認証が使用されます。 基本認証や Windows 認証など、他の認証方法を有効にする Web サイト、Web アプリケーション、または Web サービスに対して匿名認証を無効にする必要があります。
互換性
バージョン | メモ |
---|---|
IIS 10.0 | <anonymousAuthentication> 要素は IIS 10.0 では変更されませんでした。 |
IIS 8.5 | <anonymousAuthentication> 要素は IIS 8.5 では変更されませんでした。 |
IIS 8.0 | <anonymousAuthentication> 要素は IIS 8.0 では変更されませんでした。 |
IIS 7.5 | <anonymousAuthentication> 要素は、IIS 7.5 では変更されませんでした。 |
IIS 7.0 | <anonymousAuthentication> 要素が IIS 7.0 で導入されました。 |
IIS 6.0 | <anonymousAuthentication> 要素は、IIS 6.0 AuthFlags、AnonymousUserName、AnonymousUserPassword メタベースのプロパティを置き換えます。 |
段取り
<anonymousAuthentication>
要素は IIS 7 の既定のインストールに含まれています。
操作方法
匿名認証を無効にする方法
インターネット インフォメーション サービス (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) マネージャー] をダブルクリックします。
[接続] ウィンドウで、サーバー名を展開し、[サイト] を展開し、構成する階層ウィンドウのレベルに移動し、Web サイトまたは Web アプリケーションを選択します。
[ホーム] ウィンドウの [セキュリティ] セクションまでスクロールし、[認証] をダブルクリックします。
[認証] ウィンドウで [匿名認証] を選択し、[操作] ウィンドウで [無効] を選択します。
IUSR アカウントから匿名認証の資格情報を変更する方法
インターネット インフォメーション サービス (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) マネージャー] をダブルクリックします。
[接続] ウィンドウで、サーバー名を展開し、[サイト] を展開し、構成する階層ウィンドウのレベルに移動し、Web サイトまたは Web アプリケーションを選択します。
[ホーム] ウィンドウの [セキュリティ] セクションまでスクロールし、[認証] をダブルクリックします。
[認証] ウィンドウで [匿名認証] を選択し、[操作] ウィンドウで [編集] を選択します。
[匿名認証資格情報の編集] ダイアログ ボックスで、次のいずれかを実行します。
アプリケーション プールの ID セットを使用するアプリケーション プール ID を選択し、[OK] を選択します。
[設定] を選択し、[資格情報の設定] ダイアログ ボックスの [ユーザー名] ボックスにアカウントのユーザー名を入力し、[パスワード] ボックスと [パスワードの確認] ボックスにアカウントのパスワードを入力し、[OK] を選択して、もう一度 [OK] を選択します。
Note
この手順を使用する場合は、IIS サーバー コンピューターで新しいアカウントに最小限の特権のみを付与します。
構成
<anonymousAuthentication>
要素は、Web.config ファイル内のサイトおよびアプリケーション レベルで構成できます。
属性
属性 | 説明 | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
enabled |
省略可能な Boolean 属性です。 匿名認証を有効にするかどうかを指定します。 既定値は true です。 |
||||||||||
logonMethod |
省略可能な列挙型属性。 logonMethod 属性には、次のいずれかの値を指定できます。 既定値は、 ClearText です。
|
||||||||||
password |
省略可能で、 String 型の属性。 匿名認証のパスワードを指定します。 注: 暗号化されていないパスワード文字列を構成ファイルに格納しないようにするには、常に AppCmd.exe または IIS マネージャーを使用してパスワードを入力してください。 これらの管理ツールを使用する場合、パスワード文字列は XML 構成ファイルに書き込まれる前に自動的に暗号化されます。 これで、暗号化されていないパスワードを格納するよりも、パスワードのセキュリティが向上します。 |
||||||||||
username |
省略可能で、 String 型の属性。 匿名認証のユーザー名を指定します。 この値を空白のままにすると (つまり、username="")、匿名認証はアプリケーション プール ID を使用して匿名ユーザーを認証します。 既定値は IUSR です。 |
子要素
なし。
構成サンプル
次の構成例では、IIS 7 Web サイトまたは Web アプリケーションに対して、Web サーバー上のローカル アカウントを使用するように匿名認証を構成します。 (IIS 7 では、AES 暗号化を使用してパスワードが自動的に暗号化されます)。
<security> <authentication>
<anonymousAuthentication
userName="User1"
password="[enc:AesProvider:57686f6120447564652c2049495320526f636b73:enc]" />
</authentication>
</security>
サンプル コード
次の例では、匿名認証を有効にし、匿名認証に使用される既定のユーザー名とパスワードを IUSR という名前のアカウントと P@ssw0rd というパスワードに変更します。
AppCmd.exe
appcmd.exe set config "Contoso" -section:system.webServer/security/authentication/anonymousAuthentication /enabled:"True" /commit:apphost
appcmd.exe set config "Contoso" -section:system.webServer/security/authentication/anonymousAuthentication /userName:"IUSR" /commit:apphost
appcmd.exe set config "Contoso" -section:system.webServer/security/authentication/anonymousAuthentication /password:"P@ssw0rd" /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 anonymousAuthenticationSection = config.GetSection("system.webServer/security/authentication/anonymousAuthentication", "Contoso");
anonymousAuthenticationSection["enabled"] = true;
anonymousAuthenticationSection["userName"] = @"IUSR";
anonymousAuthenticationSection["password"] = @"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.GetApplicationHostConfiguration
Dim anonymousAuthenticationSection As ConfigurationSection = config.GetSection("system.webServer/security/authentication/anonymousAuthentication", "Contoso")
anonymousAuthenticationSection("enabled") = True
anonymousAuthenticationSection("userName") = "IUSR"
anonymousAuthenticationSection("password") = "P@ssw0rd"
serverManager.CommitChanges()
End Sub
End Module
JavaScript
var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST";
var anonymousAuthenticationSection = adminManager.GetAdminSection("system.webServer/security/authentication/anonymousAuthentication", "MACHINE/WEBROOT/APPHOST/Contoso");
anonymousAuthenticationSection.Properties.Item("enabled").Value = true;
anonymousAuthenticationSection.Properties.Item("userName").Value = "IUSR";
anonymousAuthenticationSection.Properties.Item("password").Value = "P@ssw0rd";
adminManager.CommitChanges();
VBScript
Set adminManager = CreateObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"
Set anonymousAuthenticationSection = adminManager.GetAdminSection("system.webServer/security/authentication/anonymousAuthentication", "MACHINE/WEBROOT/APPHOST/Contoso")
anonymousAuthenticationSection.Properties.Item("enabled").Value = True
anonymousAuthenticationSection.Properties.Item("userName").Value = "IUSR"
anonymousAuthenticationSection.Properties.Item("password").Value = "P@ssw0rd"
adminManager.CommitChanges()