ServerValidator: A tool to validate your server’s configuration
Introduction
To become a WebMatrix hosting provider, you have to fulfill a checklist of requirements. For example, you must have Web Deploy installed and configured properly on your server. We have made a tool called ServerValidator which can help you run through the checklist and understand if your server is configured properly.
ServerValidator is a general-purpose tool which can be used in your own server provisioning workflow to determine if the right components are installed. ServerValidator ships with a sample input file which checks for WebMatrix-specific requirements, but you can change the input file to suit your own needs and run your own validations.
A couple of notes …
- Interested in becoming a WebMatrix hosting partner? Please read the documentation here; contact us at whg at microsoft dot com if you have questions.
- Use of ServerValidator outside of the Web Hosting Gallery program is not supported by Microsoft Customer Support Services. However, I will be happy to hear your feedback and fix bugs as much as possible!
Obtaining and running ServerValidator
You can get a ZIP file which contains ServerValidator here. The tool will work on x86 and x64 architectures.
1. The ServerValidator ZIP file comes with a sample configuration file, WebMatrixValidation.xml, which contains validation checks for WebMatrix support. You can run ServerValidatorUI with this file to start with to get a feel for what the tool does.
2. Open the folder where you unzipped ServerValidator
3. Right-click ServerValidatorUI.exe and click "Run as Administrator". This is required for several of the validations to succeed because they require elevated privileges on your server.
4. Inspect the results in the UI
Have feedback?
Please let us know at baslam at microsoft dot com
ServerValidator Architecture
At a basic level, ServerValidator reads an input file telling it what Validations to run, runs them and saves the result in a report:
Input File Format
The input file is a well-formatted XML file. It looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<Validations>
<!-- Server SKU Check -->
<Validation
id="CheckOsWindowServer2008R2"
type="OsValidator"
validOperatingSystems="Microsoft Windows Server 2008 R2"
description="Check if operating system is Windows Server 2008 R2"
detailsUrlBase="http://go.microsoft.com/fwlink/?LinkId=206559"
tags="spotlight"
/>
<Validation
id="SomeUniqueId"
type="IdOfValidator"
key1="value1"
key2="value2"
description="Simple description of this validator"
detailsUrlBase="http://go.microsoft.com/fwlink/?LinkId=206559"
/>
</Validations>
· Comments are allowed in the input XML using standard comment tags.
· Each validation is specified by a <Validation></Validation> tag, and is handles by a specific Validator in the ServerValidator.Validators namespace.
· Type is a required attribute
· The value for this attribute specifies a .NET type in the ServerValidator.Validators namespace that implements the IValidator interface. For example, let’s say type =”MyValidator”. ServerValidator ships with a number of built-in Validators – it first searches the ServerValidator.dll assembly for “ServerValidator.Validators.MyValidator”. If one is not found, it tries to load the “MyValidator.dll” assembly from disk and looks for the “ServerValidator.Validators.MyValidator” type in it.
· description attribute is required. It should be a simple description of the Validation.
· detailsUrlBase attribute is required. It should be a URI of the documentation.
· The remaining attributes are optional and are passed as key-value pairs to the Validator itself.
The output file is named localhost_<timestamp>.xml and is placed in the same folder as ServerValidator. A sample report looks like this:
<?xml version="1.0"?>
<Report>
<Date>12/2/2010 2:33:32 PM</Date>
<Version>0.0.0.0</Version>
<Server>localhost</Server>
<Validations>
<Validation id="CheckOsWindowServer2008R2" result="Fail">
<Events>
<Event type="Fail" timeOccurred="2:33:00 PM">Current OS Microsoft Windows 7 Enterprise is not in list of valid operating systems</Event>
</Events>
</Validation>
<Validation id="CheckNetFramework35Installed" result="Pass">
<Events>
<Event type="Pass" timeOccurred="2:33:03 PM">Product .NET Framework 3.5 SP 1 is installed.</Event>
</Events>
</Validation>
</Validations>
</Report>
Validator |
Description |
COMValidator |
Checks for the presence of a COM component |
DelegationRuleValidator |
Checks if Web Deploy delegation rules are set up correctly |
GacAssemblyValidator |
Checks if a assembly is GAC’ed |
OsValidator |
Checks if the operating system is in the list of valid operating systems |
RegistryValidator |
Checks if a registry key is present and has a specific value |
ServiceValidator |
Checks if a service is installed and is the expected state |
WebPIInstalledProductValidator |
Checks if a product that can be installed via WebPI is installed. Also checks if all applications in the Application Gallery have dependencies installed. |
WindowsInstalledComponentValidator |
Checks if a product in the Windows Programs Control Panel is installed or not. Use this for programs that are not installed using WebPI. |
Example: COMValidator
Check if a specific COM component is installed:
<Validation
type="COMValidator"
name="OldFont"
description="Check if a COM component is installed"
detailsUrlBase="http://go.microsoft.com/fwlink/?LinkId=206559"
/>
Example: DelegationRuleValidator
Checks if the following delegation rules are set up correctly in administration.config: createApp, iisApp, contentPath, dbFullSql, dbMySql, recycleApp, setAcl. This Validator does not take any input:
<Validation
id="CheckWebDeployDelegationRules"
type="DelegationRuleValidator"
description="Check if Web Deploy delegation rules for non-administrators are set up correctly"
detailsUrlBase="http://go.microsoft.com/fwlink/?LinkId=206559"
/>
Note that this Validator does NOT check the following:
· createApp: RunAs identity has write access to applicationHost.config
· recycleApp: RunAs identity is a member of the Administrators security group
Example: OsValidator
Checks if the current operating system is in the comma-seperated list of valid operating systems specifed in the validOperatingSystems attribute:
<Validation
id="CheckOsWindowServer2008R2"
type="OsValidator"
validOperatingSystems="Microsoft Windows Server 2008 R2"
description="Check if operating system is Windows Server 2008 R2"
detailsUrlBase="http://go.microsoft.com/fwlink/?LinkId=206559"
/>
Example: RegistryValidator
Checks the registry for the presence of a key and, optionally, a registry value, kind and data
<Validation type="RegistryValidator"
id="CheckWmsvcTracingEnabled"
regKey="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WebManagement\Server"
regValue="TracingEnabled"
regValueKind="DWord"
regValueData="1"
description="Check if tracing for Web Management Service (wmsvc) is enabled"
detailsUrlBase="http://go.microsoft.com/fwlink/?LinkId=206559"
/>
The regKey attribute is required, all other attributes are optional.
Valid values for regKey: HKEY_LOCAL_MACHINE\..., HKEY_CURRENT_USER\..., HKEY_CLASSES_ROOT\..., HKEY_USERS\..., HKEY_CURRENT_CONFIG\...
Valid values for regValueKind: String, ExpandString, Binary, DWord, MultiString, QWord.
Example: ServiceValidator
Checks if a Windows service is installed and, optionally, in the correct state:
<Validation
id="CheckWmsvcStarted"
type="ServiceValidator"
serviceName="wmsvc"
serviceState="Running"
description="Check if Web Management Service (wmsvc) is started"
detailsUrlBase="http://go.microsoft.com/fwlink/?LinkId=206559"
/>
The serviceName attribute is required. serviceState attribute is optional.
Valid values for serviceState: Paused, Running, Stopped.
Example: WebPiInstalledComponentValidator
This Validator serves two purposes. First, it can be used to check if a product installed using the WebPI 3.0 feed is installed or not. This snippet checks if Microsoft ASP.NET is installed. Valid values for the productId are productIds in the WebPI feed.
<Validation
id="CheckWDeployInstalled"
type="WebPIInstalledProductValidator"
productId="WDeploy"
category="product"
description="Check if Web Deploy 2.0 is installed"
detailsUrlBase="http://go.microsoft.com/fwlink/?LinkId=206559"
/>
Second, it can be used to check if dependencies for all applications that can be installed using the Web Application Gallery are installed. This is valuable if you want to see if your server supports being a publishing target for Wordpress, Joomla! etc. It will highlight any missing components so you can install them:
<Validation
id="CheckAppGalleryDependenciesInstalled"
type="WebPIInstalledProductValidator"
category="appgalleryapplications"
description="Check if dependencies for all applications in Microsoft Web Application Gallery are installed"
detailsUrlBase="http://go.microsoft.com/fwlink/?LinkId=206559"
/>
Example: WindowsInstalledComponentValidator
This Validator uses WMI to check if a product is in Win32_Products. It’s an alternative to the WebPIInstalledComponentValidator, because it checks the same list as the Programs Control Panel, and can also check for Windows Updates.
Valid values for category attribute: product and update.
<Validation
id="CheckExtensionlessHotfixInstalled"
type="WindowsInstalledComponentValidator"
name="980368"
category="update"
description="Check if hotfix for enabling extensionless URLs on IIS7 is installed"
detailsUrlBase="http://go.microsoft.com/fwlink/?LinkId=206559"
tags="spotlight"
/>
Building your own Validator
1. Start Visual Studio
2. Create .NET 2.0, C# class library project:
3. Add a reference to ServerValidator.dll:
4. Paste the following code into MyCustomValidator.cs:
using System.Collections.Generic;
using ValidationResult = ServerValidator.ILog.ValidationResult;
namespace ServerValidator.Validators
{
public class MyCustomValidator : ServerValidator.Validators.IValidator
{
private Dictionary<string, string> _context;
private Server _server;
private ServerValidationManager _serverValidationManager;
public override void Initialize(Dictionary<string,string> context, Server server, ServerValidationManager serverValidationManager)
{
_context = context;
_server = server;
_serverValidationManager = serverValidationManager;
_serverValidationManager.Reporter.Log(ILog.LogEvent.LogEventType.Informational, "Initialized my custom validator");
}
public override ValidationResult Validate()
{
_serverValidationManager.Reporter.Log(ILog.LogEvent.LogEventType.Informational, "Called Validate() in my custom validator");
return ValidationResult.Pass;
}
}
}
Each Validator implements the IValidator interface. It must be in the ServerValidator.Validators namespace. It overrides two methods:
· Initialize method. Called to set up the Validator with input data:
· context: set of key-value pairs specified for this Validator in the input XML.
· server: reserved for future use
· serverValidationManager: provides access to logging capabilities
· Validate method. This method actually does the work of validation. Use the Reporter field on the instance of ServerValidationManager to perform logging.
5. Compile the DLL and place it in the same directory as ServerValidatorCommandLine.exe
6. Add the following snippet to the input file:
<Validation
type="MyCustomValidator"
key1="value1"
key2="value2"
description="My custom validator"
detailsUrlBase="http://www.foosomerandomsite.com"
/>
7. Run ServerValidator