[英]How do I set up a site in IIS7 on Windows 2008 Server Web SP2 via a console application?
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. 我有一个在Windows Server 2003上使用过的程序,该程序在IIS6中设置了一个我过去使用过的站点,而过去没有任何问题。
I'm trying to do the same thing with Windows 2008 Server Web SP2 and I'm getting an error. 我正在尝试使用Windows 2008 Server Web SP2做同样的事情,但出现错误。 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. 我发现Microsoft提供了一个程序集
Microsoft.Web.Administration
,使IIS7可以使我的任务更加轻松。 However I'm getting an error when I run the application. 但是,运行应用程序时出现错误。 The error reported says:
报告的错误说:
"The specified HTTPS binding is invalid".
“指定的HTTPS绑定无效”。
I'm not specifying an https binding though so I'm not sure why I'm getting the error message. 我没有指定https绑定,所以我不确定为什么会收到错误消息。 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. 同样,此任务必须更新Web场中的多个服务器。 Does anyone know how to modify the code to make this happen?
有谁知道如何修改代码来实现这一目标?
iisManager.Sites.Add(site.Name.ToString(), "http:", "*:80:" + domain,
server.InetPath + site.Name);
Remove the domain, if you're like me you didn't add the second ':' after the port 删除域,如果您像我一样,则没有在端口后添加第二个“:”
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. 若要使用
Microsoft.Web.Administration
API在远程服务器上创建和操作IIS,可以使用ServerManager.OpenRemote(string serverName)
方法。
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. 但是我感觉您可能需要在具有正确权限的Active Directory用户的上下文中运行此服务器,因为无法为远程服务器提供凭据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.