Tool to generate AhAdmin code for actions in IIS7 UI
If you ever write AhAdmin code, this is for you.I have written a tool which generates equivalent JavaScript/C#/VB.Net AhAdmin code for actions done in IIS7 UI.
IIS7 configuration system gives access to IIS config files via a set of COM APIs. You can read/write to IIS configuration using these APIs in a script or C/C++ or using any of the managed language. All the tools which are shipped with IIS like managed APIs (Microsoft.Web.Administration), UI (IIS Manager), WMI provider uses these COM APIs internally to perform all the configuration operations. When you do an action in the UI, UI is making calls to these COM APIs (actually via MWA). Programming against COM APIs provided by IIS configuration system requires extensive understanding of these APIs and also IIS schema. Also you are required to know what exactly you want to change in the configuration. So when if you want to enable IIS detailed error messages programmatically, you are required to know which property should be changed to what value to have the desired effect. IIS Manager does present the properties in more readable form which makes it easier to decide what changes you want to make to the system which is helpful to the administrators but not developers. Imagine if you could just do an operation using IIS Manager and get the equivalent AhAdmin code which you can copy-paste in your application. This is exactly what AhAdminCodeGenerator is written to do. In the snapshot below, you are looking at JavaScript code generated when I created a site using IIS Manager.
How does it work?
Features
1. Supports both Vista RTM and Vista Sp1 (and Win2K8) version of AhAdmin interface.
2. Generates JavaScript, C# and VB.Net code for UI actions.
3. Standard features like find text, goto line, copying/saving code etc are included.
Installation and how to use steps
To install this tool, download attached file AhAdminCodeGeneratorInstall.zip, unzip and run the installer (AhAdminCodeGeneratorInstall.EXE).
To use the tool, do the following.
1. Run AhAdminCodeGenerator.exe as elevated.
2. If you are using this tool on vista RTM system, click IIS Manager->Use Vista RTM version.
3. Click IIS Manager->Start or press F5.
4. Do actions in UI and see the equivalent code in the AhAdmin code generator. Use the code as you see fit.
Note: AhAdmin code generator will not work on x64 systems as this tool uses detours express edition and not professional edition which supports x64.
Note: Because of the way this tool works, you cannot use it when IIS Manager is connected to a remote box.
Note: Default settings will make this tool emit code for write calls only. You can change call capture options and code generation options to control what code is generated.
Capture and code generation Options
You can use capture options window to configure what API calls you are interested in. Defaults are set based on what APIs are mostly used when UI is reading/writing configuration. In most cases, you won't need to change this. Code generation options defaults are set to generate code for write calls only. Also by default, code for all GetMetadata and SetMetadata calls won't be generated. These defaults helps to remove code of all read calls which UI is making to display data. If you are really interested in seeing code for read calls as well, you can change code generation options accordingly. Warning: IIS Manager is not super efficient in reading configuration. You will see lot of unwanted code if you turn on code for read configuration calls.
Generating code
Snapshot below has JavaScript code which got generated when I created an application pool with managed runtime version as 1.1.
C# code which got generated when I created a web site is shown below. Notice code generated at the bottom to start the web site. This part of the code will only get generated if you run the tool on Vista Sp1 or Win2K8. Vista RTM didn't have dynamic properties functionality which is getting used by the UI in Vista Sp1 and Win2K8 to start the site.
As a final example, following VB.Net code gets generated if you disable anonymous authentication and enable basic authentication for a site.
-Kanwal-