Irwin
Irwin

Reputation: 12819

How do you list all the web sites (not applications) being hosted by an IIS server?

I'm using IIS 6 on Windows Server 2003. The vision is to create a directory of those applications, showing their urls (ports on Server) and names.

Upvotes: 3

Views: 1198

Answers (3)

this. __curious_geek
this. __curious_geek

Reputation: 43207

In addition to above solutions, assuming if your application is not running on the same server machine where the IIS is, in that case you will need to write a TCPClient to perform Reverse DNS on the IP of the IIS server.

By defination Reverse DNS means:

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

Upvotes: 0

Icebob
Icebob

Reputation: 1196

C# example: link text

or

This is a VB example, 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

Upvotes: 0

Grzenio
Grzenio

Reputation: 36649

I haven't done it, but I believe 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
}

Upvotes: 2

Related Questions