My goal is to get a list of website names from a remote server. But I get an exception:
The RPC server is unavailable.
Here is the code:
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; }
this works great when the firewall is off on the machine.
What do I need to know which port is used by DirectoryEntry? or is there another way to get website names without disabling the firewall?
source share