tags:

views:

38

answers:

1

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?

A: 

To use the Microsoft.Web.Administration API to create and manipulate IIS on a remote server you can use the ServerManager.OpenRemote(string serverName) method.

However I've a feeling you probably need to run this in the context of an Active Directory user with the correct rights on the remote server as there is no way of providing credentials for the remote server.

Kev
Thanks, I'll give that a try.
geoff swartz
I've setup impersonation for the program and I've read that I need to give that user permissions to the windows\system32\inetsrv\config directory. I'm connecting as a local administrator on that machine who has read/write access to those files but I still get the unauthorized access error. Does anyone know what else I need to do? Thanks.
geoff swartz