How do you list all websites (not applications) hosted on an IIS server?

I use IIS 6 in Windows Server 2003. Vision - Create a directory of these applications by showing their URLs (ports on the server) and their names.

+3
source share
3 answers

I did not do this, but I believe that you need to use the following WMI object:

DirectoryEntry w3svc = new DirectoryEntry(string.Format("IIS://{0}/w3svc", serverName));
foreach (DirectoryEntry site in w3svc.Children)
{
     //these are the web sites, lookup their properties to see how to extract url
}
+2
source

C # example: link text

or

This is an example of VB, but I think you will use this idea: link text

strComputer = "."

Set objWMIService = GetObject _
("winmgmts:{authenticationLevel=pktPrivacy}\\" _
    & strComputer & "\root\microsoftiisv2")
Set colItems = objWMIService.ExecQuery("Select * from IIsWebVirtualDir")
For Each objItem in colItems
  Wscript.Echo "Application Isolated: " & objItem.AppIsolated
  Wscript.Echo "Application Package ID: " & objItem.AppPackageID
  Wscript.Echo "Application Package Name: " & objItem.AppPackageName
  Wscript.Echo "Application Root: " & objItem.AppRoot
  Wscript.Echo "Installation Date: " & objItem.InstallDate
  Wscript.Echo "Name: " & objItem.Name
Next
0
source

In addition to the solutions above, assuming your application does not work on the same server as IIS, in this case you will need to write TCPClient to perform Reverse DNS on the IIS IP server.

Curing Reverse DNS means:

In computer networks, reverse DNS lookup or reverse DNS resolution (rDNS) is the definition of a domain name associated with a given IP address using the Internet Domain Name System (DNS).

0
source

Source: https://habr.com/ru/post/1711652/


All Articles