Recipe 12.15. Enabling Direct Metabase EditingProblemYou want to edit the metabase while IIS is still running. You may need to do this to configure metabase properties that are not accessible from the GUI. SolutionUsing a graphical user interface
You can now use Notepad or some other text editor to edit the %SystemRoot%\system32\inetsrv\MetaBase.xml file as desired while IIS is running. Using a command-line interfaceTo enable edit-while-running from the local server's command line, you have to first stop all IIS services: > iisreset /stop Use a text editor to open the metabase configuration file %SystemRoot%\system32\inetsrv\MetaBase.xml and change the line: EnableEditWhileRunning = "0" to: EnableEditWhileRunning = "1" Save your changes and then type the following command to restart IIS services: > iisreset /start Using VBScript' This code enables the direct metabase editing setting ' ------ SCRIPT CONFIGURATION ------ strComputer = "<ServerName>" ' ------ END CONFIGURATION --------- set objServer = GetObject("IIS://" & strComputer) objServer.EnableEditWhileRunning = 1 objServer.EnableHistory = 1 objServer.SetInfo WScript.Echo "Successfully enabled direct metabase editing on server " & _ objServer.Name DiscussionWhen IIS is running, it uses an in-memory copy of the metabase. If you make a change to the metabase, the change takes effect immediately in the in-memory metabase, and 60 seconds later IIS writes the changes to the MetaBase.xml file on disk. If, however, another metabase change is made before the 60 seconds are up, the timer resets to 60 seconds again (this can happen five times). Saving your IIS configuration or stopping the IISAdmin service also flushes the in-memory metabase to disk. Be careful when modifying the metabase directlyif you make a mistake and the metabase becomes corrupted, IIS may not start and you'll have to restore the metabase from backup (see Recipe 12.16). When possible, try to avoid editing the metabase directly and use the GUI or a programmatic method instead. The IIS 6 Resource Kit Tools includes Version 1.6 of Metabase Explorer (MBExplorer.exe), a graphical tool that you can use to view and edit the metabase on local or remote IIS computers. MBExplorer replaced MetaEdit tool on older versions of IIS. Figure 12-4 shows MBExplorer focused on the default web site. Figure 12-4. MBExplorer view of the default web site
Using VBScriptTo enable direct metabase editing using ADSI, you have to set the EnableEditWhileRunning and EnableHistory properties to 1. The EnableHistory property causes IIS to create a backup copy of the metabase every time the in-memory version of the metabase is written to disk. This is a precautionary measure to ensure that you don't get yourself into too much trouble by corrupting the metabase. With the history feature, you can restore previous versions of the metabase. See AlsoRecipe 12.16, MS KB 814871 (INFO: IIS 6.0 Metabase Documentation), and MS KB 267904 (SAMPLE: Metaacl.exe Modifying Metabase Permissions for the IIS Admin Objects) |