Having troubles when i want to create a new server using servermanager.
Here's my code
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();
When i run it, it creates server + bindings, but it gives the following error:
"Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"
which occurs when sm.CommitChnages() is run.
I can't figure out which what i don't have access to. Any ideas?
You have to run this piece of code with a local administrator account.
For ASP.NET applications, your choices are
Both of them have something you need to pay attention to on security side,