Introducing the Reporting Services WMI Provider

Windows Management Instrumentation (WMI) classes are included in Reporting Services to allow the report server and Report Manager components to be controlled on local and remote computers, to provide a way to discover which machines in the network that are running a Report Server Web service, and to activate a report server instance into a scale-out deployment. System administrators and database administrators can use these classes to make changes to the configurations of the report server and Report Manager after installation is complete, or to perform local or remote server administration tasks. Tasks include modifying the database connection credentials between the report server and the report server database, modifying the name of the report server database, and changing the URL that defines the installation path to the report server instance or Report Manager.

The classes installed to support these functions are as follows:

  • The MSReportServer_ConfigurationSetting Class represents the installation and run-time parameters of a report server instance. These parameters are stored in the RSReportServer.config configuration file for the report server.
  • The MSReportServer_ConfigurationSettingForSharePoint Class represents the installation and run-time parameters of a report server instance that is configured for SharePoint integrated mode. These parameters are stored in the RSReportServer.config configuration file for the report server.
  • The MSReportManager_ConfigurationSetting Class represents the installation and run-time parameters of a Report Manager instance. These parameters are stored in the RSWebApplication.config configuration file for Report Manager.

The namespace used to obtain information about Reporting Services in the code samples shown in this topic is the System.Management namespace, found in the Microsoft .NET Framework. The System.Management namespace provides a set of managed code classes through which .NET Framework applications can access and manipulate management information. For more information on using the Reporting Services WMI classes using the System.Management namespace, see "Accessing Management Information with System.Managment" in the Microsoft .NET Framework SDK.

If the computer has multiple instances of a report server installed, the administrator needs to point to the exact instance on the computer whose properties are being modified. To directly find the instance, each class contains a property that is defined as a key. This key property uniquely identifies a report server installation. The property defined as a key is the PathName property. The value of this property is the path to the RSReportServer.config configuration file, including the name of the configuration file. For most installations, this path would be similar to the following example:

C:\Program Files\Microsoft SQL Server\MSSQL\Reporting Services\ReportServer\rsreportserver.config

After the MSReportServer_ConfigurationSetting class is created, you can populate the key and search the computer for an instance of the report server or Report Manager that matches that key. If found, populate the management collection with the rest of the values from that instance.

You can also obtain information by populating a collection and looping through the management class to display the information. If you are running this code from Visual Studio, add a project reference to System.Management. The example below assumes that the RSReportServer.config configuration file is located in C:\Program Files\Microsoft SQL Server\MSSQL.n\Reporting Services\ReportServer\bin. The descriptions for the methods in the System.Management class can be found in the Microsoft .NET Framework SDK.

The preferred way of finding information on your report server installations is to enumerate through the WMI instance collection. The example below shows how to find properties on every report server instance by creating a collection, and looping through the collection to display the properties.

using System;
using System.Management;
using System.IO;
[assembly: CLSCompliant(true)]

class Class1
{
    [STAThread]
    static void Main(string[] args)
    {
        const string WmiNamespace = @"\\localhost\root\Microsoft\SqlServer\ReportServer\v9\Admin";
        const string WmiRSClass =
          @"\\localhost\root\Microsoft\SqlServer\ReportServer\v9\admin:MSReportServer_ConfigurationSetting";
        ManagementClass serverClass;
        ManagementScope scope;
        scope = new ManagementScope(WmiNamespace);

        // Connect to the Reporting Services namespace.
        scope.Connect();
        // Create the server class.
        serverClass = new ManagementClass(WmiRSClass);
        // Connect to the management object.
        serverClass.Get();
        if (serverClass == null)
            throw new Exception("No class found");

        // Loop through the instances of the server class.
        ManagementObjectCollection instances = serverClass.GetInstances();

        foreach (ManagementObject instance in instances)
        {
            Console.Out.WriteLine("Instance Detected");
            PropertyDataCollection instProps = instance.Properties;
            foreach (PropertyData prop in instProps)
            {
                string name = prop.Name;
                object val = prop.Value;
                Console.Out.Write("Property Name: " + name);
                if (val != null)
                    Console.Out.WriteLine("     Value: " + val.ToString());
                else
                    Console.Out.WriteLine("     Value: <null>");
            }
        }
        Console.WriteLine("\n--- Press any key ---");
        Console.ReadKey();
    }
}

For more information about the properties that can be read or changed on the report server and Report Manager, see Reporting Services WMI Provider Library. For more information on the properties specific to the report server, see MSReportServer_ConfigurationSetting Class. For more information on the properties specific to the Report Manager, see MSReportManager_ConfigurationSetting Class. For information on the default installation of the configuration files, see Reporting Services Configuration Files.

Change History

Release History

12 December 2006

New content:
  • The MSReportServer_ConfigurationSettingForSharePoint Class

Community Additions

ADD
Show: