共用方式為


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
已淘汰.

取得或設定值,這個值表示是否應允許 NTLM 驗證做為 Windows SSPI Negotiate 驗證。

ClientCredential

取得或設定 Windows 用戶端認證。

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於