March 2008 - Posts

A few months back I posted[^] about the RC0 release of IIS Manager for Windows XP, 2k3 and Windows Vista. We've now released the RTM version which works with Windows 2008 (and we've removed the previous installs from www.iis.net).

Both Bob and Carlos have posted about this and both have some good information on their blogs (Carlos also has a video posted on some of the new features:

The new download URLs are:

Most of the instructions from my last post (Managing IIS 7 (RCO) from Windows XP, 2k3 and Vista[^]) should still apply to these installers although some of the screenshots may be a bit different.

Note: You will need Windows Vista SP1 in order for remote manager to install and work on Vista and you should also have the IIS Manager console installed (my last post covers to install the management console on Vista: http://blogs.iis.net/bdela/archive/2007/10/08/remote-administration-managing-iis-7-rco-from-windows-xp-2k3-and-vista.aspx#InstallingMgtConsole [^]

In my last post[^] I gave a quick overview of how to extend configuration. More specifically I covered extending configuration by adding new sections to configuration. One thing I also mentioned was that you can extending existing configuration sections too - that's what this post is about.

Extending the "sites" section
To show how to extend existing configuration I'm going to add two new attributes which are configurable for sites. We're going to an an owner and an ownerEmail attribute (a slightly less contrived example than the last post :-)

Note: do not do this on a production environment - you should never, ever, ever play around with extending configuration on a system that is in production use!

  1. In the %windir%\system32\inetsrv\config\schema directory, create a file called extendExisting.xml
  2. Add the following to the file:
    <configSchema>
     
    <sectionSchema name="system.applicationHost/sites">
       
    <collection addElement="site">
         
    <attribute name="owner" type="string" />
          <
    attribute name="ownerEmail" type="string" />
        </
    collection>
     
    </sectionSchema>
    </configSchema>

Ok, that's it - we've extended schema. Just remember, when extending the schema of an existing section, simply create a <sectionSchema> element and set the name attribute to be the same as an existing section. In the schema file above, we have defined a <sectionSchema> with a name of system.applicationHost/sites - this is the same as the sectionSchema name in the IIS_Schema.xml file in the Schema directory.

Testing the new attributes
Let's do a quick test to see if our new attributes are working. Run the following command to add an owner and ownerEmail to the "Default Web Site":

%windir%\system32\inetsrv\appcmd set site "Default Web Site" /owner:"Master Chief" /ownerEmail:"john117@contoso.com"

You can quickly check to see if the configuration has been applied by running the following:

%windir%\system32\inetsrv\appcmd list site "Default Web Site" /config

Your output should look something like the following:

<system.applicationHost>
 
<sites>
    ...
   
<site name="Default Web Site" id="1" siteOwner="Master Chief" siteOwnerEmail="john117@contoso.com"></site>
    ...
 
</sites>
</system.applicationHost>

Done :-)

More On Extensibility
This was a very short example of how to extend existing configuration sections. I'll be posting a few more entries about config system extensibility over the next few days and I'll cover extending config with code (including adding configuration 'methods') and a few other things.

My last post, IIS 7 Configuration: Basic Configuration Extensibility[^], covered the basics of configuration extensibility.

In the mean time, have a read of this Config System Extensibility article I published a while back: http://learn.iis.net/page.aspx/241/configuration-extensibility/

In IIS 7 we introduced a completely new configuration system which is used by the IIS runtime and all our administration tools. The configuration system is based on distributed XML files that contain the configuration for IIS, ASP.NET and other components; flexibility in the configuration system also allows for configuration to be set at a a number of levels including at the server, the site and the application level. Configuration at the site and application level coexists alongside ASP.NET configuration in web.config files.

One of my favourite and in my opinion one of the coolest features of our new config system is that the configuration system itself is extensible. You can quickly and easily extend config with your own attributes, collections, etc. and in fact we use config system extensibility on some of the downloadable modules we ship (e.g. FTP 7.0, and some more to come in the near future... you'll see them on IIS.NET in the next few days)

What do I mean by extensible?
Well, the config system is XML based and configuration definition exists in schema files which are located at %windir%\system32\inetsrv\config\schema. You can go there and look at the IIS_schema.xml file to see the schema definition of the IIS 7 config system. (As a side note, looking at the pre-installed files in the schema directory is a great way to learn more about configuration options in IIS 7.)

So, by extensibility I mean you have the ability to extend configuration with your own schema and get the full usage of the IIS 7 configuration APIs automatically. You can create new configuration sections, extend existing sections and you can even have configuration which is backed by a COM components...

Which begs the question... why?

Simple answer: Open up rscaext.xml and have a look there - we extended our own configuration system to provide additional functionality for you.

If you Install FTP 7 (download here[^] - note that you'll have to remove FTP 6 if it's installed) and then look at the new schema file it adds you'll see that we extend existing configuration sections and add news ones... the FTP runtime can make use of one of the plethora of ways to interact with the config system (appcmd.exe,  native config API, managed config api, etc.) There was no need to build a new config system or manually parse XML files.

Adding a new config section
Ok, so lets add a new config section - in this case, a very contrived one. We're going to add a new configuration section under system.webServer called Ireland with an attribute called nationalHoliday.

Note: do not do this on a production environment - you should never, ever, ever play around with extending configuration on a system that is in production use!

  1. In the %windir%\system32\inetsrv\config\schema directory, create a file called ireland.xml
  2. Add the following to the file:
    <configSchema>
     
    <sectionSchema name="system.webServer/ireland">
         
    <attribute name="nationalHoliday" type="string" />
      </
    sectionSchema>
    </configSchema>

    Next, we need to register our new configuration section so that the configuration system will recognize the schema as being valid and in use.

  3. Open the primary IIS configuration file, %windir%\system32\inetsrv\config\applicationHost.config.
  4. Look for the <configSections> section and add to <section name="ireland"/> under the system.webServer sectionGroup. You should have something like:
  5. <configSections>
      ...
     
    <sectionGroup name="system.webServer">
       
    <section name="ireland"/>
        ...
      </
    sectionGroup>
    </configSections>

That's it. Configuration has been extended. So, let's test it. Run the following command at the command line:

%windir%\system32\inetsrv\appcmd list config -section:system.webServer/ireland

You should get output of:

<system.webServer>
 
<ireland />
</
system.webServer>

Now, let's set the national holiday for the Default Web Site - just run:

appcmd set config "Default Web Site" -section:system.webServer/ireland /nationalHoliday:"St. Patricks Day"

Now, let's check the config for default web site:

%windir%\system32\inetsrv\appcmd list config "Default Web Site" -section:system.webServer/ireland

You're output should be something like:

<system.webServer>
 
<ireland nationalHoliday="St. Patricks Day" />
</
system.webServer>

 

Wohoo!!! We've just extended config with a very contrived example. You could now read that configuration using all of the config system APIs.

More On Extensibility
This was a very short example of how to do basic extensibility. I'll be posting a few more entries about config system extensibility over the next few days and I'll cover extending existing sections, extending config with code (including adding configuration 'methods') and a few other things.

In the mean time, have a read of this Config System Extensibility article I published a while back: http://learn.iis.net/page.aspx/241/configuration-extensibility/

More Posts