問題:新しい IIS アプリケーション プールが作成され、アクセス許可にアプリケーション プール ID を使用するように設定されている場合、これらの ID を管理者やパフォーマンス カウンター ユーザーなどのユーザー グループに追加する方法がわかりません。
背景:現在、次のことを行うために Microsoft.Web.Administration を使用する C#.NET ライブラリを作成しています。
- IIS 7.x がインストールされているかどうかを検出し、インストールされている場合はどのコンポーネントかを検出します。
- IIS 7.x を必要なコンポーネントの提供されたリストにインストールまたはアップグレードします。
- IIS を介して 1 つまたは複数の Web サイトを作成/管理します。
- Web サイトごとに 1 つのアプリケーション プールを自動的に作成/管理
このライブラリは、大規模なソフトウェア展開の一部として、Windows Server OS 上で Web サーバーおよび Web サイト/サービスの自動展開を提供するために、実行可能インストーラーによって使用されるということです。これまでのところ、アプリケーション プール/Web サイトの作成で実行する必要があるいくつかのアクセス許可の自動化を除いて、上記のすべてが実装、テストされ、(ほとんど) 機能しています。
新しい Web サイトをインストールするための私の方法では、新しいアプリケーション プールを作成し、アプリケーション プール ID を使用するように強制します。
static public void InstallSite(string name, string path, int port)
{
Site site;
var appPoolName = ApplicationPoolBaseName + name;
using (var iisManager = new ServerManager())
{
// Set up a custom application pool for any site we run.
if (!iisManager.ApplicationPools.Any(pool => pool.Name.Equals(appPoolName)))
{
iisManager.ApplicationPools.Add(appPoolName);
iisManager.ApplicationPools[appPoolName].ManagedRuntimeVersion = "v4.0";
}
iisManager.CommitChanges();
}
// ... other code here ('site' gets initialized) ...
using (var iisManager = new ServerManager())
{
// Set anonymous auth appropriately
var config = iisManager.GetWebConfiguration(site.Name);
var auth = config.GetSection("system.web/authentication");
auth.SetMetadata("mode", "Windows");
var authSection = config.GetSection("system.webServer/security/authentication/anonymousAuthentication");
authSection.SetAttributeValue("enabled", true);
authSection.SetAttributeValue("userName", string.Empty); // Forces the use of the Pool's Identity.
authSection = config.GetSection("system.webServer/security/authentication/basicAuthentication");
authSection.SetAttributeValue("enabled", false);
authSection = config.GetSection("system.webServer/security/authentication/digestAuthentication");
authSection.SetAttributeValue("enabled", false);
authSection = config.GetSection("system.webServer/security/authentication/windowsAuthentication");
authSection.SetAttributeValue("enabled", false);
iisManager.CommitChanges();
}
// ... other code here ...
}
私が理解しているように、これが最善のセキュリティ プラクティスであり、特定の Web サイトに最小限のシステム アクセス以上のアクセス許可を追加します。このプロセスの一部として、これらのアプリケーション プール ID を管理者やパフォーマンス モニター ユーザーなどのユーザー グループに追加します。ここで合併症が発生します。
現在、他の場所で文書化されているように、各アプリケーション プール ID は の形式で存在しますがIIS AppPool\\<pool_name>
、この偽のユーザーは、通常の GUI ユーザー管理コントロールを介してリストされておらず、 SO でこの例System.DirectoryServices.AccountManagement
に従う場合など、ライブラリを介してアクセスできないようです。また、アプリケーション プール ID に関する他の質問は、インストール コンテキスト内からではなく、子 Web サイト内からの参照に関連しているようです。
それで、誰かが適切な方法が何であるかを知っていますか
- a) プログラムによるアプリケーション プール ID の参照とアクセス。
- b) ユーザー グループを追加して、アプリケーション プール ID のアクセス許可を付与します。