azure web app上的用户权限问题(ApplicationPool - Identity)

时间:2015-10-26 14:49:52

标签: azure azure-web-sites application-pool applicationpoolidentity

我正在尝试以编程方式更改我的Azure Azure应用程序托管的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 to LocalSystem。

我在天蓝色托管网络应用上没有特定用户(管理员或本地管理员)的用户名和密码。

欢迎任何不同的方法或想法或变通方法。

1 个答案:

答案 0 :(得分:2)

您无法更改运行Azure Web App的App Pool标识。 Web应用程序以sandboxed environment执行,通常不允许进行此类修改。

有上传证书的方法,如果您正在尝试实现这一目标,您可能想要特别提出这个问题。