我正在尝试以编程方式更改托管我的 azure Web 应用程序的 IIS 服务器的 ApplicationPool - Identity 属性。
我为什么要这样做?
我需要提供 X.509 证书。实施此证书需要一些本地系统数据。
到目前为止我做了什么?
我使用这个特定的代码(与这里几乎相同https://stackoverflow.com/a/9341347/2900305)
private void SetAppPoolIdentity()
{
string appPoolUser = "myRDP_admin_user";
string appPoolPass = "my_super_secure_password";
Action<string> iis7fix = (appPoolName) =>
{
bool committed = false;
while (!committed)
{
try
{
using (ServerManager sm = new ServerManager())
{
var applicationPool = sm.ApplicationPools[appPoolName];
applicationPool.ProcessModel.IdentityType = ProcessModelIdentityType.SpecificUser;
//applicationPool.ProcessModel.IdentityType = ProcessModelIdentityType.LocalSystem;
applicationPool.ProcessModel.UserName = appPoolUser;
applicationPool.ProcessModel.Password = appPoolPass;
sm.CommitChanges();
committed = true;
}
}
catch (FileLoadException fle)
{
Trace.TraceError("Trying again because: " + fle.Message);
}
}
};
var appPoolNames = new ServerManager().Sites.First().Applications.Select(x => x.ApplicationPoolName).ToList();
appPoolNames.ForEach(iis7fix);
}
我的问题是我的用户没有足够的权限将 ApplicationPool - Identity 更改为 LocalSystem。
而且我没有 azure 托管 Web 应用程序上特定用户(管理员或本地管理员)的用户名和密码。
欢迎任何不同的方法或想法或解决方法。