Share via


Lesson 2: 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 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.

important Important 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 the Runas command to run IIS Manager as an administrator. From the command prompt, type runas /user:administrative_accountname "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

  1. 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?

  2. As you may recall from Lesson 3: Organizing Data from the IIS Metabase, 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

  1. 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.
  2. Expand CIM_ManagedSystemElement (click the plus sign beside it), then expand CIM_Logical.
    All the IIS object classes are listed.
  3. 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.

In Lesson 2: Organizing Information, we talked about how 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. In Lesson 3: Organizing Data from the IIS Metabase, we learned that 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.

To sum up what we learned in this lesson, we looked at the following:

  • The representation of an IIsWebServer object, and its schematic definition in the metabase schema file, the IIS MOF file, and CIM Studio.
  • An instance of the IIsWebServer object, which was the Default Web Site, in the metabase configuration file and CIM Studio.
  • How the IIsWebServer object was split in WMI into a class with the read-only properties and methods, and a class with the writable properties.
  • How CIM Studio is useful in viewing the properties that are accessible by any class, and the parameters of class methods.
    This is important when writing administration scripts in Module 3: Writing Administration Scripts that use WMI of this tutorial.