C# 如何获得财产;“启动模式”;正在运行的应用程序池的
我在检查正在运行的应用程序池的特定属性时,编写了一段平静的代码。到目前为止,我得到了“Enable32BitAppOnWin64”、“IdentityType”、“UserName”和“Password”。现在,我尝试获取属性“开始模式”。但我无法在任何级别上找到这个属性。有人知道怎么得到这个吗 命名空间自动测试 { 类AppPoolUser {C# 如何获得财产;“启动模式”;正在运行的应用程序池的,c#,iis,properties,application-pool,C#,Iis,Properties,Application Pool,我在检查正在运行的应用程序池的特定属性时,编写了一段平静的代码。到目前为止,我得到了“Enable32BitAppOnWin64”、“IdentityType”、“UserName”和“Password”。现在,我尝试获取属性“开始模式”。但我无法在任何级别上找到这个属性。有人知道怎么得到这个吗 命名空间自动测试 { 类AppPoolUser { }使用配置元素类(应用程序类从中派生)的.Attributes来访问 Output_Handler OutputHandler = new
}使用
配置元素
类(应用程序
类从中派生)的.Attributes
来访问
Output_Handler OutputHandler = new Output_Handler();
public string ServiceUser { get; set; } = ".\\Administrator";
public string ServiceUserPassword { get; set; } = "admin";
public void ExecuteAppPoolUserCheck()
{
CheckExistingApplicationPool("Platform Services (RO) App Pool", true);
CheckExistingApplicationPool("Platform Services App Pool", true);
CheckExistingApplicationPool("Processes App Pool", false);
CheckExistingApplicationPool("Settings App Pool", true);
CheckExistingApplicationPool("Web App Pool", true);
}
private void CheckExistingApplicationPool(string applicationPoolName, bool is64Bit)
{
ApplicationPool applicationPool = GetApplicationPool(applicationPoolName);
if (applicationPool != null)
{
if (is64Bit)
{ CheckAppPoolBitnessfor64BitAppPool(applicationPool); }
else { CheckAppPoolBitnessfor32BitAppPool(applicationPool); }
}
else
{
return;
}
CheckApplicationPoolUser(applicationPool);
CheckApplicationPoolStartMode(applicationPool);
}
private ApplicationPool GetApplicationPool(string appPoolName)
{
var serverManager = new ServerManager();
try
{
ApplicationPool appPool = serverManager.ApplicationPools[appPoolName];
return appPool;
}
catch (Exception ex)
{
logger.Debug(ex, "Application Pool " + serverManager.ApplicationPools[appPoolName] + " does not exist");
return null;
}
}
private void CheckAppPoolBitnessfor32BitAppPool(ApplicationPool applicationPool)
{
//boolean == true
if (applicationPool.Enable32BitAppOnWin64)
{
OutputHandler.ColorCMDOutput("The AppPoolBitness 32Bit is correctly set for " + applicationPool.Name, ConsoleColor.Green);
}
else
{
OutputHandler.ColorCMDOutput("The AppPoolBitness 32Bit is NOT correctly set for " + applicationPool.Name, ConsoleColor.Red);
OutputHandler.AppendDataToFile(@"C:\Users\Public\TestFolder\Buglist.txt", "The AppPoolBitness 32BIT is NOT correctly set for " + applicationPool.Name);
}
}
private void CheckAppPoolBitnessfor64BitAppPool(ApplicationPool applicationPool)
{
//boolean == false
if (!applicationPool.Enable32BitAppOnWin64)
{
OutputHandler.ColorCMDOutput("The AppPoolBitness 64BIT is correctly set for " + applicationPool.Name, ConsoleColor.Green);
}
else
{
OutputHandler.ColorCMDOutput("The AppPoolBitness 64BIT is NOT correctly set for " + applicationPool.Name, ConsoleColor.Red);
OutputHandler.AppendDataToFile(@"C:\Users\Public\TestFolder\Buglist.txt", "The AppPoolBitness 64BIT is NOT correctly set for " + applicationPool.Name);
}
}
private void CheckApplicationPoolUser(ApplicationPool applicationPool)
{
if (applicationPool.ProcessModel.IdentityType != ProcessModelIdentityType.SpecificUser)
{
OutputHandler.ColorCMDOutput("The AppPoolIdentitytype \"SpecificUser\" is NOT correctly set for " + applicationPool.Name + ". The currently Set value is \"" + applicationPool.ProcessModel.IdentityType.ToString() + "\"", ConsoleColor.Red);
OutputHandler.AppendDataToFile(@"C:\Users\Public\TestFolder\Buglist.txt", "The AppPoolIdentitytype \"SpecificUser\" is NOT correctly set for " + applicationPool.Name + ". The currently set value is \"" + applicationPool.ProcessModel.IdentityType.ToString() + "\"");
return;
}
else
{
OutputHandler.ColorCMDOutput("The AppPoolIdentitytype \"SpecificUser\" is correctly set for " + applicationPool.Name, ConsoleColor.Green);
}
{
if (applicationPool.ProcessModel.UserName != ServiceUser)
{
OutputHandler.ColorCMDOutput("The AppPoolUserame \"Administrator\" is NOT correctly set for " + applicationPool.Name + ". The currently set value is \"" + applicationPool.ProcessModel.UserName.ToString() + "\"", ConsoleColor.Red);
OutputHandler.AppendDataToFile(@"C:\Users\Public\TestFolder\Buglist.txt", "The AppPoolUserame \"Administrator\" is NOT correctly set for " + applicationPool.Name + ". The currently set value is \"" + applicationPool.ProcessModel.UserName.ToString() + "\"");
}
else
{
OutputHandler.ColorCMDOutput("The AppPoolUserame \"Administrator\" is correctly set for " + applicationPool.Name, ConsoleColor.Green);
}
if (applicationPool.ProcessModel.Password != ServiceUserPassword)
{
OutputHandler.ColorCMDOutput("The AppPoolPassword \"admin\" is NOT correctly set for " + applicationPool.Name + ". The currently set value is \"" + applicationPool.ProcessModel.Password.ToString() + "\"", ConsoleColor.Red);
OutputHandler.AppendDataToFile(@"C:\Users\Public\TestFolder\Buglist.txt", "The AppPoolPassword \"admin\" is NOT correctly set for " + applicationPool.Name + ". The currently set value is \"" + applicationPool.ProcessModel.Password.ToString() + "\"");
}
else
{
OutputHandler.ColorCMDOutput("The AppPoolPassword \"admin\" is correctly set for " + applicationPool.Name, ConsoleColor.Green);
}
}
}
private void CheckApplicationPoolStartMode(ApplicationPool applicationPool)
{
}
}