Using CIM Studio to Understand the IIS Metabase

This topic explains the relationship between the IIS metabase and the structure of WMI, and compares it with the structure of ADSI. A tool called CIM Studio walks you through the IIS WMI provider and the IIS metabase at the same time. CIM Studio comes with the WMI Administrative Tools, which can be downloaded from MSDN. For more information about downloading CIM Studio, see Information.

It is strongly recommended that you install CIM Studio and use it as instructed to learn to use the IIS WMI provider more quickly. If you are already familiar with WMI, it is recommended that you skim through this section.

IIS 5.1 and earlier: The IIS WMI provider is not available.

To familiarize yourself most efficiently with the IIS WMI provider, review the information on managing IIS in IIS Manager, the IIS metabase schema and configuration file, the IIS Managed Object Format (MOF) file, and CIM Studio. Most systems have management GUIs that are tedious to use if you have large amounts of data or frequent management tasks. But the GUI is the most modular way to learn how to manage a system, so it is used here as an orientation. The IIS metabase schema and configuration files are used to emphasize the difference between the structure of the IIS metabase and the data it contains that is unique to your machine. The IIS MOF file and CIM Studio give you a pictorial representation of the IIS WMI provider. If you have the tools for the IIS Resource Kit installed, another useful tool to have open is the Metabase Editor which acts like a CIM Studio for IIS ADSI interface; however, this tutorial does not reference the Metabase Editor tool.

To open IIS Manager

  1. From the Start menu, click Run.

  2. In the Open box, type inetmgr, and click OK.

For alternate methods to open IIS Manager, see IIS Manager.

ms525342.alert_caution(en-us,VS.90).gifImportant Note:

If you incorrectly change data in the Metabase Schema file in its original location, IIS cannot function. Changing the Metabase Configuration File is allowed, and if done correctly, the results are the same as using IIS Manager to change properties and settings (see Editing the MetaBase.xml File While IIS Is Running). If you change the IIS MOF file, the IIS WMI provider cannot function. For safety reasons, the steps below instruct you to make copies of these files and work from the copies.

To open the IIS metabase schema file

  1. From the Start menu, click Run.

  2. In the Open box, type Notepad %systemroot%\System32\Inetsrv\mbschema.xml.

  3. From the File menu in Notepad, click Save As.

  4. In the File name box, type C:\mbschema, and click Save. This saves the file to C:\mbschema.txt so you can safely modify the file without altering the configuration IIS.

To open the IIS metabase configuration file

  1. From the Start menu, click Run.

  2. In the Open box, type Notepad %systemroot%\System32\Inetsrv\metabase.xml, and click OK.

  3. From the File menu in Notepad, click Save As.

  4. In the File name box, type C:\metabase, and click Save. This saves the file to C:\metabase.txt so you can safely modify the file without altering the configuration of IIS.

To open the IIS WMI provider MOF file

  1. From the Start menu, click Run.

  2. In the Open text box, type Notepad %systemroot%\System32\wbem\iiswmi.mof, and click OK.

  3. From the File menu in Notepad, click Save As.

  4. In the File name text box, type C:\iiswmi, and click Save. This saves the file to C:\iiswmi.txt so you can safely modify the file without altering the configuration of IIS.

After you download the WMI Administrative Tools from MSDN, WMI Tools should appear in the Start menu. For more information about downloading CIM Studio, see Information.

To open CIM Studio

  1. From the Start menu, click All Programs, point to WMI Tools, then click WMI CIM Studio. This opens an instance of Internet Explorer containing the CIM Studio tool. You may get an error message that says "VBScript: Possible Version Incompatibility" if the tool is a pre-release version, but that is just a disclaimer until the final version is released. Click OK.

  2. When the Connect to Namespace dialog box appears, click Cancel. This dialog box appears only the first time you open CIM Studio. Anytime thereafter that you want to browse to a WMI namespace, you can click the button with the computer icon to the right of the Classes in dialog box in the main Internet Explorer window. In this tutorial, the button with the computer icon is referred to in order to reduce confusion.

  3. Click the button with the computer icon to the right of the Classes in dialog box. The Browse for Namespace dialog box opens.

  4. In the Machine name box, type \\ and the name of the machine on which IIS 6.0 is installed. The default is the local machine name.

  5. In the Starting namespace box, type root\MicrosoftIISv2. This tells CIM Studio that you want to connect to the IIS WMI provider on the above machine. If you want to see a list of other providers that are accessible, leave the starting namespace as root.

  6. Click Connect. The WMI CIM Studio Login dialog box opens.

  7. Click Options to view the entire dialog box.

  8. If the machine you are connecting to lists you as an administrator, you can leave the check box for Login as current user selected. If you aren't listed as an administrator, clear the Login as current user check box and enter an administrator user name and password in the appropriate fields.

  9. In the Impersonation level box, verify that Impersonate is selected.

  10. In the Authentication level box, verify that Packet is selected. Select the Enable all privileges box only if you want to be able to change properties in the IIS metabase using CIM Studio.

  11. Click OK to connect. If an Access Denied error appears, check your user name and password to make sure they are correct.

  12. If you left the Starting namespace box as root in step 5, the Browse for namespace dialog box opens again. Expand the root directory to see all the available WMI providers, select MicrosoftIISv2, and click OK to connect to the IIS WMI provider.

  13. The CIM Studio window loads all the classes for the IIS WMI provider in the left frame. All the classes that start with a "__" are inherited from the root namespace. The other five classes are CIM_ManagedSystemElement, CIM_Setting, IIsStructuredDataClass, CIM_Component, and CIM_ElementSetting.

Viewing the Properties and Methods of the IIS WMI Provider

Now that you have three views of IIS open, this lesson helps you make connections between the content of each as you browse through properties and methods in CIM Studio.

Note

This lesson assumes that you have the IIS Web service installed, but you can also follow along if you have the IIS FTP service, the SMTP service, or the NNTP service installed instead because they are all types of service classes. The difference is that the property names are different.

ms525342.alert_caution(en-us,VS.90).gifImportant Note:

You must be a member of the Administrators group on the local computer to perform the following procedure (or procedures), or you must have been delegated the appropriate authority. As a security best practice, log on to your computer using an account that is not in the Administrators group, and then use Runas to open a command window from which you can run other programs like IIS Manager. From a command prompt, type Runas /user:domain_or_machine_name\administrative_account_name "cmd /k" to open a command window under secure credentials. To open IIS Manager from the secure command window, type mmc %systemroot%\system32\inetsrv\iis.msc.

To view the default Web site

  1. In IIS Manager, expand the Web Sites folder, right-click Default Web Site and click Properties to view the configuration properties for the default Web site.

  2. Click the Web Site tab, and in the Description box, Default Web Site is selected by default.

  3. Click the Home Directory tab, and in the Local path box, C:\Inetpub\Wwwroot is selected by default if you installed Windows on the C: drive.

  4. Open Notepad, and open the IIS configuration file, MetaBase.txt, and from the Edit menu, click Find, and in the Find what box, type Default Web Site. You should find the following block of text:

     < IIsWebServer 
        Location ="/LM/W3SVC/1" AppPoolId="DefaultAppPool" 
        DefaultDoc="Default.htm,Default.asp,index.htm,iisstart.asp,Default.aspx" 
        SecureBindings=":443:" 
        ServerBindings=":80:" 
        ServerComment="Default Web Site" 
        ServerSize="1" 
    > 
    </IIsWebServer> 
    
  5. The metabase files use Extensible Markup Language (XML) format, which is similar to HTML. The Default Web Site is an instance of the IIsWebServer class. The ServerComment property matches the Description box in IIS Manager. Where is the property that matches the Local path box in IIS Manager? In the MetaBase.txt file, search for C:\Inetpub\Wwwroot to find the following text:

    < IIsWebVirtualDir 
        Location ="/LM/W3SVC/1/ROOT" 
        AccessFlags="AccessRead | AccessScript" 
        AppFriendlyName="Default Application" 
        AppIsolated="2" 
        AppPoolId="DefaultAppPool" 
        AppRoot="/LM/W3SVC/1/ROOT" 
        HttpErrors="400,*,FILE,F:\WINNT\help\iisHelp\common\400.htm 
        ... 
        Path="c:\inetpub\wwwroot" 
    > 
    </IIsWebVirtualDir> 
    
  6. The Default Web Site appears to also be a virtual directory, or in other words, an instance of the IIsWebVirtualDir class. This is because all Web sites must have a root virtual directory (notice the difference between the Location properties of each class). The Path property matches Local path in IIS Manager. The property sheet for the Default Web Site shows both the IIsWebServer properties and the IIsWebVirtualDir properties. Open the IIS schema file, MBSchema.txt, in Notepad and search for the schema of the IIsWebServer class until you find the following line:

    <Collection InternalName =" 
    IIsWebServer" MetaFlagsEx="NOTABLESCHEMAHEAPENTRY | CONTAINERCLASS" MetaFlags="HASUNKNOWNSIZES" ContainerClassList="IIsObject,IIsCertMapper,IIsFilters,IIsWebVirtualDir" InheritsPropertiesFrom="MetabaseBaseClass"> 
    
  7. Under that line are all the properties that belong to the IIsWebServer class. ServerComment is listed among them. In the MBSchema.txt file, search for IIsWebVirtualDir until you find the following line:

    <Collection InternalName =" 
    IIsWebVirtualDir" MetaFlagsEx="NOTABLESCHEMAHEAPENTRY | CONTAINERCLASS" MetaFlags="HASUNKNOWNSIZES" ContainerClassList="IIsWebDirectory,IIsWebFile,IIsWebVirtualDir,IIsObject" InheritsPropertiesFrom="MetabaseBaseClass"> 
    
  8. Under that line is the schema for the Path property.

  9. So far, you are looking at the schema and configuration of the IIS metabase, without reference to WMI. WMI is, after all, only a tool to access the metabase programmatically. Now open IisWmi.txt in Notepad, and search for IIsWebServer until you find the following line:

    class  
    IIsWebServer :  
    CIM_LogicalElement 
    
  10. This is the definition of the IIsWebServer class, which WMI uses to access any instance of an IIS Web site. IIsWebServer is a subclass of the CIM_LogicalElement class, which in turn is a subclass of the CIM_ManagedSystemElement class. Notice that there are far fewer properties listed as members of this class than are listed under the metabase schema <Collection> tag for IIsWebServer. Where are all the other properties? Where is ServerComment?

  11. The CIM_ManagedSystemElement class contains only the read-only properties and methods for an object. Look at the above excerpt from the IisWmi.txt file to see lines that begin with [Implemented. These lines define the methods contained in the IIsWebServer class. All the writable properties are under the matching element class in the CIM_Setting class, in this case, IIsWebServerSetting. In the IisWmi.txt file, search for IIsWebServerSetting until you find the following line:

    class IIsWebServerSetting : IIsSetting 
    
  12. Under that line is the definition for the ServerComment property. All properties start with [Key or [read. [Key indicates that the property is the identification key for the element, and is usually the Name property. CIM Studio graphically displays the IIS MOF file (or any service's MOF file). As a bonus, CIM Studio can also display instances of any class so that you can view current configuration settings on your Web server. View the Internet Explorer window that contains CIM Studio. Where is the IIsWebServer class? As you saw in the IisWmi.txt file, it is a subclass of the CIM_LogicalElement class, which in turn is a subclass of the CIM_ManagedSystemElement class.

  13. Expand CIM_ManagedSystemElement (click the plus sign beside it), then expand CIM_Logical. All the IIS object classes are listed.

  14. Click IIsWebServer. The read-only properties, methods, and associations are displayed in the right frame. The Name property is marked with a key icon to identify it as the key of the element.

To view instances of the IIsWebServer class (to view the Web sites that are on your server)

  • Click Instances above the right frame that looks like a window with two frames. If you are unsure which button you are looking at, let the mouse cursor hover over the button and Instances should pop up. On a default installation, only one instance appears; W3SVC/1. All the fields in the row correspond to the read-only properties for IIsWebServer, and in the fields are the current values in the metabase configuration file.

When you write administration scripts to read or change properties in the metabase, it helps to use the metabase files, the IIS MOF file, or CIM Studio to know which properties are available to an object. An advantage of CIM Studio is that you can view the parameters that you need to pass to a method.

To view parameters of a method

  1. Click Instances again to go back to the schematic view.

  2. Click the Methods tab.

  3. Right-click a method name and click Edit Method Parameters. A window appears listing the parameters of the method. While there are no parameters for the methods of the IIsWebServer object, but there are for the IIsWebService object.

Organization in WMI is dictated by the needs of inheritance. The IIsWebService class is a prime example. The IIS services take advantage of inheritance of base service classes by being subclasses of those base service classes. To find IIsWebService, look under CIM_ManagedSystemElement, CIM_Service, Win32_BaseService, Win32_Service. This level of nesting does not make programmatic access difficult because you can directly refer to the IIsWebService class when writing a script.

To view the parameters of the IIsWebService object

  1. Click IIsWebService in the left frame.

  2. Click the Methods tab in the right frame.

  3. Right-click CreateNewSite and click Edit Method Parameters.

If you write a script that creates a new Web site using this method, you need to call the method with the following syntax:

siteID = IIsWebServiceObj.CreateNewSite("My New Site", arrBindings, "C:\Inetpub\NewSite")

Is the ServerId parameter (fourth parameter) missing? No, it is optional, as you can see by right-clicking ServerId in the right frame of CIM Studio and clicking Parameter Qualifiers. The OPTIONAL qualifier is set to true.

To view the writable properties of the IIsWebServer object

  • In the left frame of CIM Studio, expand CIM_Setting, expand IIsSetting, and click IIsWebServerSetting. Again, you can click Instances in the right frame to view the current configuration settings of all of the Web sites on your server.

Go back to the schematic view of IIsWebServerSetting and click the Associations tab. This is how WMI determines that IIsWebServerSetting is related to IIsWebServer of the CIM_ManagedSystemElement class. This association is represented under the CIM_ElementSetting class as the IIsWebServer_IIsWebServerSetting class.

Go back to the IIsWebServer class and click the Associations tab. The association to IIsWebServerSetting is there, but so are several others. The other associations represent containment of one class in another, allowing for inheritance of some properties and methods. Each containment association is represented under the CIM_Component class.

Finally, there is the IIsStructuredDataClass. This class contains elements that were represented in a complicated, error-prone manner in ADSI. You should become familiar with the elements of this class and their properties. Notice that they are not associated with any other class. They can exist on their own. As we saw in the parameters of the CreateNewSite method, an array of instances of these elements can be passed to methods.