连接到远程2008服务器上的IIS元数据库

时间:2010-02-11 16:31:50

标签: c# security iis windows-server-2000 metabase

我编写了一些代码来检查iis元数据库,以查看安装了哪些站点以及保存虚拟目录的位置。在服务器上本地运行时,这些代码运行正常。

我正在尝试扩展它以便远程工作。我正在努力让它进行身份验证。我目前正在使用LogonUser api,但这在登录时始终返回false

  • 我知道我的证书很好
  • 我与服务器之间没有防火墙
  • 如果我在没有LogonUser API调用和命令行用户runas的情况下运行应用程序,我会收到错误消息:COMException (0x80005000)

任何想法都会受到赞赏。

1 个答案:

答案 0 :(得分:0)

通常,如果您在远程服务器上执行程序化管理,则需要将凭据传递给API。例如,如果您使用的是System.DirectoryServices,那么您可以执行以下操作:

string server = "MyHost";
string username = "bob";
string password = "bob123$";
string path = "IIS://" + server + "/W3SVC/1";

DirectoryEntry de = new DirectoryEntry(path, username, password);
相关问题