当我想使用 servermanager 创建新服务器时遇到麻烦。
这是我的代码
ServerManager sm = new ServerManager();
Site s = sm.Sites.Add("NEWSERVER", path, 80);
BindingCollection bindingCollection = s.Bindings;
bindingCollection.Clear();
Binding binding = s.Bindings.CreateElement("binding");
binding["protocol"] = "https";
binding["certificateHash"] = "thumprint value";
binding["certificateStoreName"] = "MY";
binding["bindingInformation"] = string.Format("{0}:{1}:{2}", "*", "443", "subdomain.url.com");
bindingCollection.Add(binding);
Binding binding2 = s.Bindings.CreateElement("binding");
binding2["protocol"] = "http";
binding2["bindingInformation"] = string.Format("{0}:{1}:{2}", "*", "80", "subdomain.url.com");
bindingCollection.Add(binding2);
s.ServerAutoStart = true;
ApplicationPool a = sm.ApplicationPools.Add("NEWSERVER");
a.ManagedRuntimeVersion = "v4.0";
s.ApplicationDefaults.ApplicationPoolName = "NEWSERVER";
sm.CommitChanges();
当我运行它时,它会创建服务器 + 绑定,但会出现以下错误:
“访问被拒绝。(来自 HRESULT 的异常:0x80070005 (E_ACCESSDENIED))”
这在 sm.CommitChnages() 运行时发生。
我无法弄清楚我无法访问哪些内容。有任何想法吗?