我正在编写一个小型web应用程序,该应用程序允许我在我们的网络上的不同服务器上管理多个IIS安装。我们没有域控制器。ADSI/IIS管理和ASP.NET模拟
我写了一个使用win32 api和它的LogonUser方法的小型模拟控制器。然后,我使用System.DirectoryServices和IIS ADSI提供程序创建新站点。
我有以下程序(用明文字符串更好的可读性交换一些值):
if (impersonationSvc.ImpersonateValidUser("[email protected]", String.Empty, "PASSWORD))
{
string metabasePath = "IIS://" + server.ComputerName + "/W3SVC";
DirectoryEntry w3svc = new DirectoryEntry(metabasePath, "Administrator", "PASSWORD");
string serverBindings = ":80:" + site.HostName;
string homeDirectory = server.WWWRootNetworkPath + "\\" + site.FolderName;
object[] newsite = new object[] { site.Name, new object[] { serverBindings }, homeDirectory };
object websiteId = (object)w3svc.Invoke("CreateNewSite", newsite);
int id = (int)websiteId;
impersonationSvc.UndoImpersonation();
}
这当我使用网络应用程序上(SRV6)托管服务器的日常工作。新网站已创建。
如果我使用SRV5例如,我们的网络上的另一台服务器(不带域),ImpersonateValidUser工作时,DirectoryEntry的创建,但w3svc.Invoke失败,出现以下错误:
[收到COMException(0X80070005) :拒绝访问]
System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) +377678
System.DirectoryServices.DirectoryEntry.Bind() +36
System.DirectoryServices.DirectoryEntry.get_NativeObject() +31
System.DirectoryServices.DirectoryEntry.Invoke(String methodName, Object[] args) +53
...
任何人都知道我怎么能解决这个问题?
你说得对..太多的咖啡 – kitsune 2009-03-05 13:53:47