Udostępnij przez


WindowsClientCredential Klasa

Definicja

Umożliwia określenie właściwości związanych z poświadczeniami systemu Windows 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 pliku WindowsClientCredential. Następnie kod zmienia wartość AllowedImpersonationLevel na nową.

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

Umożliwia WindowsClientCredential ustawienie właściwości klienta systemu Windows używanych podczas komunikowania się z usługą. Ustawia AllowedImpersonationLevel poziom personifikacji, który usługa może zakładać podczas personifikacji klienta. Usługa ClientCredential umożliwia klientowi uwierzytelnianie przy użyciu nazwy użytkownika i hasła w usłudze. 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ły.

Pobiera lub ustawia wartość wskazującą, czy uwierzytelnianie NTLM powinno być dozwolone jako uwierzytelnianie negocjowania protokołu SSPI systemu Windows.

ClientCredential

Pobiera lub ustawia poświadczenia klienta systemu Windows.

Metody

Nazwa Opis
Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Dziedziczone od Object)
GetHashCode()

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

(Dziedziczone od Object)
GetType()

Type Pobiera bieżące wystąpienie.

(Dziedziczone od Object)
MemberwiseClone()

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

(Dziedziczone od Object)
ToString()

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

(Dziedziczone od Object)

Dotyczy