次の方法で共有


WindowsClientCredential クラス

定義

クライアントを表すために使用する Windows 資格情報に関連するプロパティを指定できます。

public ref class WindowsClientCredential sealed
public sealed class WindowsClientCredential
type WindowsClientCredential = class
Public NotInheritable Class WindowsClientCredential
継承
WindowsClientCredential

次の例では、クライアントを作成し、 WindowsClientCredentialへの参照を取得します。 その後、コードによって AllowedImpersonationLevel が新しい値に変更されます。

// Create a service host.
EndpointAddress ea = new EndpointAddress("http://localhost/Calculator");
WSHttpBinding b = new WSHttpBinding(SecurityMode.Message);
b.Security.Message.ClientCredentialType = MessageCredentialType.Windows;

// Create a client. The code is not shown here. See the WCF samples
// for an example of the CalculatorClient code.

CalculatorClient cc = new CalculatorClient(b, ea);
// Get a reference to the Windows client credential object.
WindowsClientCredential winCred= cc.ClientCredentials.Windows;
Console.WriteLine("AllowedImpersonationLevel: {0}",
    winCred.AllowedImpersonationLevel);
Console.WriteLine("AllowNtlm: {0}", winCred.AllowNtlm);
Console.WriteLine("Domain: {0}", winCred.ClientCredential.Domain);

Console.ReadLine();
// Change the AllowedImpersonationLevel.
winCred.AllowedImpersonationLevel =
    System.Security.Principal.TokenImpersonationLevel.Impersonation;

Console.WriteLine("Changed AllowedImpersonationLevel: {0}",
    winCred.AllowedImpersonationLevel);
Console.ReadLine();
// Open the calculator and use it.
//cc.Open();
//Console.WriteLine(cc.Add(11, 11));

//// Close the client.
//cc.Close();
' Create a service host.
Dim ea As New EndpointAddress("http://localhost/Calculator")
Dim b As New WSHttpBinding(SecurityMode.Message)
b.Security.Message.ClientCredentialType = _
MessageCredentialType.Windows

' Create a client. The code is not shown here. See the WCF samples
' for an example of the CalculatorClient code.
Dim cc As New CalculatorClient(b, ea)
' Get a reference to the Windows client credential object.
Dim winCred As WindowsClientCredential = cc.ClientCredentials.Windows
Console.WriteLine("AllowedImpersonationLevel: {0}", _
                 winCred.AllowedImpersonationLevel)
Console.WriteLine("AllowNtlm: {0}", winCred.AllowNtlm)
Console.WriteLine("Domain: {0}", winCred.ClientCredential.Domain)

Console.ReadLine()
' Change the AllowedImpersonationLevel.
winCred.AllowedImpersonationLevel = _
System.Security.Principal.TokenImpersonationLevel.Impersonation

Console.WriteLine("Changed AllowedImpersonationLevel: {0}", _
winCred.AllowedImpersonationLevel)
Console.ReadLine()
' Open the calculator and use it.
' cc.Open()
' Console.WriteLine(cc.Add(11, 11))
' Close the client.
' cc.Close()

注釈

WindowsClientCredentialでは、サービスとの通信時に使用される Windows クライアント プロパティの設定が有効になります。 AllowedImpersonationLevelは、クライアントを偽装するときにサービスが想定できる偽装のレベルを設定します。 ClientCredentialを使用すると、クライアントはサービスに対するユーザー名とパスワードを使用して認証できます。 AllowNtlmは、Kerberos が使用されていない場合に NTLM を使用してクライアントを認証できるかどうかを決定します。

プロパティ

名前 説明
AllowedImpersonationLevel

許可される偽装レベルを取得または設定します。

AllowNtlm
古い.

Windows SSPI ネゴシエート認証として NTLM 認証を許可するかどうかを示す値を取得または設定します。

ClientCredential

Windows クライアント資格情報を取得または設定します。

メソッド

名前 説明
Equals(Object)

指定したオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Objectの簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

適用対象