IIS 7 のアプリケーション プール内のアプリケーションの状態を、同じドメインの別のマシンから監視する必要があります。監視アプリケーションは C# で作成し、Windows サービスとして実行する必要があります。
私のサーバーで、管理者権限を持つユーザーを作成し、aspnet_regiis -ga machine\username
正常に機能するコマンドを実行します。
私の問題は、アプリケーション プールにアクセスしようとすると、COMException が「アクセスが拒否されました」というメッセージが表示されることです。私は何を間違えましたか、またはどのステップを見逃しましたか?
例としてhttp://patelshailesh.com/index.php/create-a-website-application-pool-programmatically-using-csharpのコードを使用しました。
int status = 0;
string ipAddress = "10.20.2.13";
string username = "username";
string password = "password";
try
{
DirectoryEntry de = new DirectoryEntry(string.Format("IIS://{0}/W3SVC/AppPools/MyAppPoolName", ipAddress), username, password);
//the exception is thrown here.
status = (int)de.InvokeGet("AppPoolState");
switch (status)
{
case 2:
//Running
break;
case 4:
//Stopped
break;
default:
break;
}
}
catch (Exception ex)
{
}