ConnectionOptions.Authentication プロパティ

定義

この接続の操作に使用する COM 認証レベルを取得または設定します。

public:
 property System::Management::AuthenticationLevel Authentication { System::Management::AuthenticationLevel get(); void set(System::Management::AuthenticationLevel value); };
public System.Management.AuthenticationLevel Authentication { get; set; }
member this.Authentication : System.Management.AuthenticationLevel with get, set
Public Property Authentication As AuthenticationLevel

プロパティ値

ローカルまたはリモート コンピューターへの接続に使用される COM 認証レベルを示す AuthenticationLevel 列挙値を返します。

次の例では、リモート コンピューターに接続し、リモート コンピューター上のオペレーティング システムに関する情報を表示します。 目的の ConnectionOptions 接続オプションを使用してリモート コンピューターに接続する が作成されます。

using System;
using System.Management;
public class RemoteConnect
{
    public static void Main()
    {
        // Build an options object for the remote connection
        // if you plan to connect to the remote
        // computer with a different user name
        // and password than the one you are currently using.
        // This example uses the default values.
        ConnectionOptions options =
            new ConnectionOptions();
        options.Authentication =
            System.Management.AuthenticationLevel.PacketPrivacy;

        // Make a connection to a remote computer.
        // Replace the "FullComputerName" section of the
        // string "\\\\FullComputerName\\root\\cimv2" with
        // the full computer name or IP address of the
        // remote computer.
        ManagementScope scope =
            new ManagementScope(
            "\\\\FullComputerName\\root\\cimv2", options);
        scope.Connect();

        //Query system for Operating System information
        ObjectQuery query = new ObjectQuery(
            "SELECT * FROM Win32_OperatingSystem");
        ManagementObjectSearcher searcher =
            new ManagementObjectSearcher(scope,query);

        ManagementObjectCollection queryCollection = searcher.Get();
        foreach ( ManagementObject m in queryCollection)
        {
            // Display the remote computer information
            Console.WriteLine("Computer Name : {0}",
                m["csname"]);
            Console.WriteLine("Windows Directory : {0}",
                m["WindowsDirectory"]);
            Console.WriteLine("Operating System: {0}",
                m["Caption"]);
            Console.WriteLine("Version: {0}", m["Version"]);
            Console.WriteLine("Manufacturer : {0}",
                m["Manufacturer"]);
        }
    }
}
Imports System.Management
Public Class RemoteConnect

    Public Overloads Shared Function Main( _
    ByVal args() As String) As Integer

        ' Build an options object for the remote connection
        ' if you plan to connect to the remote
        ' computer with a different user name
        ' and password than the one you are currently using
        Dim options As ConnectionOptions
        options = New ConnectionOptions
        options.Authentication = 6
        ' System.Management.AuthenticationLevel.PacketPrivacy = 6

        ' Make a connection to a remote computer.
        ' Replace the "FullComputerName" section of the
        ' string "\\FullComputerName\root\cimv2" with
        ' the full computer name or IP address of the
        ' remote computer.
        Dim scope As ManagementScope
        scope = New ManagementScope( _
            "\\FullComputerName\root\cimv2", options)
        scope.Connect()

        ' Query system for Operating System information
        Dim query As ObjectQuery
        query = New ObjectQuery( _
            "SELECT * FROM Win32_OperatingSystem")
        Dim searcher As ManagementObjectSearcher
        searcher = _
            New ManagementObjectSearcher(scope, query)

        Dim queryCollection As ManagementObjectCollection
        queryCollection = searcher.Get()

        Dim m As ManagementObject
        For Each m In queryCollection
            ' Display the remote computer information
            Console.WriteLine("Computer Name : {0}", _
                m("csname"))
            Console.WriteLine("Windows Directory : {0}", _
                m("WindowsDirectory"))
            Console.WriteLine("Operating System: {0}", _
                m("Caption"))
            Console.WriteLine("Version: {0}", m("Version"))
            Console.WriteLine("Manufacturer : {0}", _
                m("Manufacturer"))
        Next

        Return 0
    End Function
End Class

注釈

Windows 2000 以降では、WMI サービスは Connect レベル認証を要求しますが、Windows XP 以降ではパケット レベル認証を要求します。 クライアントで特定の認証設定が必要な場合は、このプロパティを使用して、この特定の接続の認証レベルを制御できます。 たとえば、クライアントがすべての通信を暗号化する AuthenticationLevel.PacketPrivacy 必要がある場合は、 プロパティを に設定できます。

プロパティ値

この接続の操作に使用する COM 認証レベル。 既定値は です AuthenticationLevel.Unchanged。これは、標準の DCOM ネゴシエーション プロセスに従って、クライアントがサーバーによって要求された認証レベルを使用することを示します。

.NET Framework のセキュリティ

直前の呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されているコードから使用することはできません。 詳細については、「 部分信頼コードからのライブラリの使用」を参照してください。

適用対象

こちらもご覧ください