I have a program that I've used on Windows Server 2003 that sets up a site in IIS6 which I've used without any problems in the past.
I'm trying to do the same thing with Windows 2008 Server Web SP2 and I'm getting an error. I'm guessing it has to do with the user account security. If this is correct, is there a way that I can get around this? Thanks.
System.Runtime.InteropServices.COMException (0x80070005):
Access is denied. at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
Edit:
I've found that Microsoft provide an assembly, Microsoft.Web.Administration
, to make my task easier with IIS7. However I'm getting an error when I run the application. The error reported says:
"The specified HTTPS binding is invalid".
I'm not specifying an https binding though so I'm not sure why I'm getting the error message. Here's the code.
using Microsoft.Web.Administration;
....
using (ServerManager iisManager = new ServerManager())
{
iisManager.Sites.Add(site.Name.ToString(), "http", "*:80:" + domain,
server.InetPath + site.Name);
iisManager.CommitChanges();
Site newSite = iisManager.Sites[site.Name];
newSite.Applications[0].ApplicationPoolName = "TrialUsers";
iisManager.CommitChanges();
}
Also, this task has to update multiple servers in a web farm. Does anyone know how to modify the code to make this happen?