Using the Reporting Services WMI Provider

Using the Reporting Services WMI Provider

SQL Server 2000

Windows Instrumentation (WMI) classes have been included in Reporting Services to allow report server and Report Manager components to be controlled on local and remote computers, to provide a way to discover the machines in the network that are running a report server Web service, and to activate a report server instance into a web farm. 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 MSReportServerReportManager_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 .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 .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

Once 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. The other method of obtaining information is by populating a collection, and looping through the management class to display the information. If you are running this code from Visual Studio .NET, add a project reference to System.Management. Also, it is assumed 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 Visual Studio .NET 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;

class Class1
  static void Main(string[] args)
    const string WmiNamespace = @"\\<servername>\root\Microsoft\SqlServer\ReportingServices\v8";
    const string WmiRSClass = 
    ManagementClass serverClass;
    ManagementScope scope;
    scope = new ManagementScope(WmiNamespace);

    // Connect to the Reporting Services namespace.
   // Create the server class.
    serverClass = new ManagementClass(WmiRSClass);
    // Connect to the management object.
    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());
          Console.Out.WriteLine("     Value: <null>");

For more information about the properties that can be read, or changed, on the report server and Report Manager, see Reporting Services WMI Provider. 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 MSReportServerReportManager_ConfigurationSetting Class. For information on the default installation of the configuration files, see Reporting Services Installation Directories and Registry Settings.

See Also

Using the Reporting Services WMI Provider

© 2016 Microsoft