Reporting Services WMI プロバイダ

Reporting Services WMI プロバイダは、エンタープライズ環境におけるアクセス制御と管理情報を目的として標準的な Windows Management Instrumentation (WMI) テクノロジに基づいて構築されています。Reporting Services の WMI プロバイダはインスタンス プロバイダとして機能し、レポート サーバー XML 構成要素をクラスのセットにマップします。これには、レポート サーバー構成情報を追加、削除、または変更するために呼び出すメソッドが含まれています。クラスの詳細については、「Reporting Services WMI プロバイダ ライブラリ」を参照してください。

WMI プロバイダの概要

Reporting Services に備わっている WMI クラスを使用すれば、ローカル コンピュータおよびリモート コンピュータ上のレポート サーバーとレポート マネージャ コンポーネントを管理し、ネットワーク内で、レポート サーバー Web サービスを実行しているコンピュータを検出する方法を提供できます。また、レポート サーバー インスタンスをアクティブ化して、スケールアウト配置に追加することも可能です。システム管理者およびデータベース管理者は、このクラスを使用して、インストールの完了後にレポート サーバーとレポート マネージャの構成を変更したり、ローカル サーバーまたはリモート サーバーの管理タスクを実行したりできます。タスクには、レポート サーバーとレポート サーバー データベース間のデータベース接続の資格情報の変更、レポート サーバー データベースの名前変更、レポート サーバー インスタンスまたはレポート マネージャへのインストール パスを定義する URL の変更があります。

これらの機能をサポートするためにインストールされるクラスは、次のとおりです。

  • MSReportServer_Instance クラスは、インストールされているレポート サーバーに接続するための基本情報をクライアントに提供します。

  • MSReportServer_ConfigurationSetting クラスは、レポート サーバー インスタンスのインストール パラメータとランタイム パラメータを表します。これらのパラメータは、レポート サーバーの RSReportServer.config 構成ファイルに保存されます。

このトピックに示すコード サンプルで Reporting Services の情報を取得するために使用する名前空間は、System.Management 名前空間です。この名前空間は Microsoft.NET Framework にあります。System.Management 名前空間により、管理情報にアクセスしてその情報を操作するときに .NET Framework アプリケーションで使用するマネージ コード クラスのセットが提供されます。System.Management 名前空間による Reporting Services の WMI クラスの使用の詳細については、Microsoft.NET Framework SDK の「System.Management による管理情報へのアクセス」を参照してください。

レポート サーバー インスタンスの検索

コンピュータにレポート サーバーの複数のインスタンスがインストールされている場合に、管理者があるインスタンスのプロパティを変更するには、コンピュータ上の正しいインスタンスをポイントする必要があります。そのインスタンスを直接検索するために、キーとして定義されるプロパティが各クラスに含まれています。このキー プロパティにより、レポート サーバーのインストールが一意に識別されます。キーとして定義されるプロパティは、PathName プロパティです。このプロパティの値は、構成ファイルの名前を含む RSReportServer.config 構成ファイルへのパスです。ほとんどのインストールでは、このパスは次の例のようになります。

C:\Program Files\Microsoft SQL Server\MSRS10.<InstanceName>\Reporting Services\ReportServer\rsreportserver.config

MSReportServer_ConfigurationSetting クラスが作成されると、キーを入力してそのキーと一致するレポート サーバーまたはレポート マネージャのインスタンスをコンピュータで検索できます。見つかった場合、そのインスタンスの残りの値を使用して管理コレクションを作成します。

また、コレクションを作成し、管理クラスをループ処理して情報を表示することによって、情報を入手することもできます。このコードを Visual Studio .NET から実行する場合は、System.Management へのプロジェクト参照を追加します。次の例は、RSReportServer.config 構成ファイルが C:\Program Files\Microsoft SQL Server\MSRS10.<InstanceName>\Reporting Services\ReportServer\bin にあることを前提とします。System.Management クラスのメソッドの説明は、Microsoft Visual Studio .NET SDK にあります。

レポート サーバーのインストールの情報を検索するさらに適切な方法は、WMI インスタンスのコレクションを使用して列挙することです。以下の例は、コレクションを作成し、コレクションによってループしてプロパティを表示することによって、レポート サーバー インスタンスごとにプロパティを検索する方法を示します。

Imports System
Imports System.Management
Imports System.IO

Module Module1
    Sub Main()
        Const WmiNamespace As String = "\\<ServerName>\root\Microsoft\SqlServer\ReportServer\<InstanceName>\v10\Admin"
        Const WmiRSClass As String = _
           "\\<ServerName>\root\Microsoft\SqlServer\ReportServer\<InstanceName>\v10\admin:MSReportServer_ConfigurationSetting"

        Dim serverClass As ManagementClass
        Dim scope As ManagementScope
        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 Is Nothing Then Throw New Exception("No class found")

        'Loop through the instances of the server class.
        Dim instances As ManagementObjectCollection = serverClass.GetInstances()
        Dim instance As ManagementObject
        For Each instance In instances
            Console.Out.WriteLine("Instance Detected")
            Dim instProps As PropertyDataCollection = instance.Properties
            Dim prop As PropertyData
            For Each prop In instProps
                Dim name As String = prop.Name
                Dim val As Object = prop.Value
                Console.Out.Write("Property Name: " + name)
                If val Is Nothing Then
                    Console.Out.WriteLine("     Value: <null>")
                Else
                    Console.Out.WriteLine("     Value: " + val.ToString())
                End If
            Next
        Next

        Console.WriteLine("--- Press any key ---")
        Console.ReadKey()


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

class Class1
{
    [STAThread]
    static void Main(string[] args)
    {
        const string WmiNamespace = @"\\<ServerName>\root\Microsoft\SqlServer\ReportServer\<InstanceName>\v10\Admin";
        const string WmiRSClass =
          @"\\<ServerName>\root\Microsoft\SqlServer\ReportServer\<InstanceName>\v10\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();
    }
}

レポート サーバーとレポート マネージャで読み取りおよび変更可能なプロパティの詳細については、「Reporting Services WMI プロバイダ ライブラリ」を参照してください。レポート サーバー固有のプロパティの詳細については、「MSReportServer_ConfigurationSetting クラス」を参照してください。構成ファイルの既定のインストールについては、「構成ファイル (Reporting Services)」を参照してください。