Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Enumerating IIS 5.0 and 6.0 hosted sites

Enumerating IIS 5.0 and 6.0 hosted sites

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netcomsysadminwindows-admin
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Adam Wimsatt
    wrote on last edited by
    #1

    I have an IIS 5.0 server hosting about 20 different websites and another IIS 6.0 hosting 3 currently.... I would like to get a list of the web addresses ( host header info in IIS ) for all these sites programmatically. I've seen some sites regarding setting up a website using System.DirectoryServices (here[^] and here[^]) but I haven't found a good way to return a list of all sites currently hosted in IIS. Any links or info would be helpful. I have been unsuccessful in finding info in MSDN... most of the info in MSDN about System.DirectoryServices is in relation to AD rather than IIS. Adam


    // TODO: Write code.

    M 1 Reply Last reply
    0
    • A Adam Wimsatt

      I have an IIS 5.0 server hosting about 20 different websites and another IIS 6.0 hosting 3 currently.... I would like to get a list of the web addresses ( host header info in IIS ) for all these sites programmatically. I've seen some sites regarding setting up a website using System.DirectoryServices (here[^] and here[^]) but I haven't found a good way to return a list of all sites currently hosted in IIS. Any links or info would be helpful. I have been unsuccessful in finding info in MSDN... most of the info in MSDN about System.DirectoryServices is in relation to AD rather than IIS. Adam


      // TODO: Write code.

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      Hi there, Basically, there are a couple of technologies which you can use to programmatically manage your IIS server, for example: Active Directory Service Interfaces (ADSI), Windows Management Instrumentation (WMI), System.DirectoryServices ..... Depending on the programming language you want to use as well as the current version of the IIS, you will choose an appropriate option. IMO, on the sites provided in your post, they use the System.DirectoryServices simply because this namespace provides an easy way to access the resources of an Active Directory service provider from managed code, and you already know that IIS is one of the current providers beside LDAP, NDS .... For more information, you can see IIS Programmatic Administration SDK [^] The sample code below prints out all virtual directories at root of the IIS server using the System.DirectoryServices:

      private void PrintIISVirtualDir()
      {
      DirectoryEntry root = new DirectoryEntry("IIS://localhost/W3SVC/1/Root");
      IEnumerator enumerator = root.Children.GetEnumerator();
      while(enumerator.MoveNext())
      {
      DirectoryEntry entry = enumerator.Current as DirectoryEntry;
      if(entry.SchemaClassName == "IIsWebVirtualDir")
      Console.Out.WriteLine("Name: " + entry.Name);
      }
      }

      You can take a quick look at the properties/members of each entry if you want to know more about the virtual directory. And here is a hierarchy of the admin objects available on the IIS server which can give you a better look: IIS Admin Object Hierarchy [^], Metabase Structure [^]. For more information

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups