【发布时间】:2012-01-23 17:03:01
【问题描述】:
我的目标是从远程服务器获取网站名称列表。但我得到了例外:
RPC 服务器不可用。
代码如下:
public List<string> GetWebSites(string serverIP)
{
List<string> names = new List<string>();
DirectoryEntry Services = new DirectoryEntry(string.Format("IIS://{0}/W3SVC", serverIP));
Services.Username = "user name";
Services.Password = "password";
IEnumerator ie = Services.Children.GetEnumerator();
DirectoryEntry Server = null;
while (ie.MoveNext())
{
Server = (DirectoryEntry)ie.Current;
if (Server.SchemaClassName == "IIsWebServer")
{
names.Add(Server.Properties["ServerComment"][0].ToString());
}
}
return names;
}
当机器上的防火墙关闭时,这工作正常。
我需要知道的是,DirectoryEntry 使用了哪些端口? 或者有没有其他方法可以在不关闭防火墙的情况下获取网站名称?
【问题讨论】:
-
它将使用(广泛的)端口。如果您需要将其强制到特定端口或更小范围,请查看here。如果我没记错的话,你还需要 UDP 389。
标签: c# iis port firewall directoryentry