Udostępnij za pośrednictwem


WindowsClientCredential Klasa

Definicja

Umożliwia określenie właściwości powiązanych z poświadczeniami systemu Windows, które mają być używane do reprezentowania klienta.

public ref class WindowsClientCredential sealed
public sealed class WindowsClientCredential
type WindowsClientCredential = class
Public NotInheritable Class WindowsClientCredential
Dziedziczenie
WindowsClientCredential

Przykłady

Poniższy przykład tworzy klienta i pobiera odwołanie do .WindowsClientCredential Następnie kod zmienia AllowedImpersonationLevel wartość na nową wartość.

// 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()

Uwagi

Ustawienie WindowsClientCredential umożliwia ustawienie właściwości klienta systemu Windows używanych podczas komunikacji z usługą. Ustawia AllowedImpersonationLevel poziom personifikacji usługi może przyjąć podczas personifikacji klienta. Dzięki ClientCredential temu klient może uwierzytelniać się przy użyciu nazwy użytkownika i hasła do usługi. Określa AllowNtlm , czy protokół NTLM może służyć do uwierzytelniania klienta, jeśli protokół Kerberos nie jest używany.

Właściwości

Nazwa Opis
AllowedImpersonationLevel

Pobiera lub ustawia dozwolony poziom personifikacji.

AllowNtlm
Przestarzałe.

Pobiera lub ustawia wartość wskazującą, czy uwierzytelnianie NTLM powinno być dozwolone jako uwierzytelnianie SSPI w systemie Windows.

ClientCredential

Pobiera lub ustawia poświadczenia klienta systemu Windows.

Metody

Nazwa Opis
Equals(Object)

Określa, czy określony obiekt jest równy bieżącemu obiektowi.

(Odziedziczone po Object)
GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetType()

Pobiera Type bieżącego wystąpienia.

(Odziedziczone po Object)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Object.

(Odziedziczone po Object)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Dotyczy