Adding site Binding programmatically IIS 7.5

176 views Asked by At

I am trying to add site binding programmatically. Here is my code:

using (ServerManager manager = ServerManager.OpenRemote("serverName"))
{
    manager.Sites["siteName"].Bindings.Add(string.Format("*:{1}:{0}.localhost", clientCode, port), "http");
    manager.CommitChanges();
}

I am getting the following Error. How do I get around this?

UnAuthorizedException: Retrieving the COM class factory for remote component with CLSID {} from machine failed due to the following error: 80070005

1

There are 1 answers

0
Lex Li On BEST ANSWER

The account runs the code must be the administrator of the remote machine and also the DCOM related ports on the remote machine must be opened at firewall.