Server Automation ToolsDancing Tools

"Software Tools to Maximize Up-time and Automate Functions in Microsoft’s Internet Information Server”


MetaBase 101. A simple tutorial on the IIS Metabase.

Metabase 101

The Metabase. What is it? What does it do? What you need to know if you plan on writing any automation in IIS.

Let's take a tour of the Metabase.

TIP: If you want to follow along real-time you will need to download and install the MetaBase. You can do that here: http://support.microsoft.com/default.aspx?scid=kb%3ben-us%3b301386#3
(If the URL is dead the Microsoft Knowledge Base Article is - 301386.)
You will also need to install IIS on your server. Ok, we'll wait....


The Metabase is used as a repository for most of - 98% - Internet Information Services's (IIS) configuration parameters. The Metabase is based on a hierarchical design with inheritance. It is fast and compact and, surprisingly, based on some things that Microsoft introduces, easy to follow, access and program.

Upon opening the Metabase you are presented with the image below. Notice the LM which stands for Local Machine. This is an object. Also, notice the object's KeyType: IIsComputer. Each object in the Metabase is defined by one KeyType.

metabase_firstlook (11K)

Let's now further traverse the Metabase by clicking on the LM object. We are presented with more objects. Of particular note too are the index values 1 thru 9. These index values actually represent the Web sites you create in IIS whether you created them using the MMC or programmatically.

Let's open the W3SVC object (this is the World Wide Web Publishing Service) and note this Object's
KeyType: IIsWebServer.

Beginning to see the pattern? :)

metabase_w3svc_image (18K)

Ok, we're almost there. This is almost too easy.

Opening the Index value 1 we discover a very familiar world.

First, look at the KeyType: IIsWebServer.

Ahhh, we finally made it! Yes, this is an actual Web site. Specifically, this is the Default Web site in IIS. Your Metabase properties for this site, most likely, mirror mine since IIS creates this by default.

defaultsite_1 (16K)

Let's move ahead just a little AND HAVE SOME FUN!

To access this site using vbscript you would code this as:

		
Dim Parent  
Dim ServerName 
Dim SiteIndex
SiteIndex = "1" 
ServerName = "www"
Set Parent = GetObject("IIS://" & ServerName & "/W3SVC/"  & SiteIndex)


Now by accessing the Parent Object (or, Container) you can extract the different parameters like the:

  • ServerComment
  • ServerState
  • ServerBindings

and take action on these parameters to add, change or delete the values. We'll take a closer look at this later.



Further traversal of the Metabase takes us to the ROOT virtual directory. When a Web site is created in IIS a ROOT virtual directory is created. This ROOT virtual directory, as well as all virtual directories, will be assigned the KeyType: IIsWebVirtualDir.

default_siteROOT (17K)

MMC_Default_Home_directory (12K)

Try this out:

  1. Open the Metabase,
  2. Open the LM://W3SVC/1/ROOT
  3. Open the MMC and
  4. Open the properties sheet for the Default web site
  5. Click on the Home Directory

Now, compare the values in the Metabase with the values in the MMC. My two images above depict this exercise BTW.

Note the similarities in each value.

Now try this:

  1. In the MMC change a value, say, the Application name
  2. Click Apply
  3. In the Metabase click View and then Refresh
Note the AppFriendlyName value you changed in the MMC now matches. It's that easy. There are no tricks.

So, let's just say your aim is to programmatically change the AppFriendlyName, you would do it like this:

		
Dim Parent  
Dim ServerName 
Dim SiteIndex
SiteIndex = 1
ServerName = "www"
Set Parent = GetObject("IIS://" & ServerName & "/W3SVC/" & SiteIndex & "/ROOT" )
Parent.AppFriendlyName = "DOGRAT"
Parent.SetInfo



Stay tuned for Metabase 102. Metabase 102 will concentrate on stepping through, line by line, the vbscript code used to automate functions in IIS.



If you like this article or maybe had a similar experience and would like to share it with other readers then feel free to:
Simply fill in YOUR e-mail address, your name and your comment. Click the SEND button.

After submitting your comment, you will be transported back to the article you commented on!

  Name E-Mail Address
You
Sending to
  Your Message



John Cesta is a contract programmer. John's current project is designer and lead developer of the automated hosting software at bestcfhosting.com, a ColdFusion MX hosting company. John is currently working on commercializing his programs and offering them to the IIS community at serverautomationtools.com