Я пишу код, в котором я проверяю конкретные свойства работающего AppPool. До сих пор я получил «Enable32BitAppOnWin64», «IdentityType», «UserName» и «Password». Теперь я пытаюсь получить свойство «Start Mode». Но я не могу найти это свойство на любом уровне. Кто-нибудь знает, как получить это?
namespace Automated_Tests
{
Класс AppPoolUser
{
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)
{
}
}
}