WindowsClientCredential Klass

Definition

Gör att du kan ange egenskaper relaterade till Windows autentiseringsuppgifter som ska användas för att representera klienten.

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

Exempel

I följande exempel skapas en klient och en referens hämtas WindowsClientCredentialtill . Koden ändrar AllowedImpersonationLevel sedan till ett nytt värde.

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

Kommentarer

Med WindowsClientCredential kan du ange Windows klientegenskaper som används vid kommunikation med en tjänst. Anger AllowedImpersonationLevel nivån för personifiering som tjänsten kan anta när klienten personifieras. ClientCredential Gör det möjligt för en klient att autentisera med användarnamn och lösenord till tjänsten. Avgör AllowNtlm om NTLM kan användas för att autentisera klienten om Kerberos inte används.

Egenskaper

Name Description
AllowedImpersonationLevel

Hämtar eller anger den tillåtna personifieringsnivån.

AllowNtlm
Föråldrad.

Hämtar eller anger ett värde som anger om NTLM-autentisering ska tillåtas som Windows SSPI Negotiate-autentisering.

ClientCredential

Hämtar eller anger Windows klientautentiseringsuppgifter.

Metoder

Name Description
Equals(Object)

Avgör om det angivna objektet är lika med det aktuella objektet.

(Ärvd från Object)
GetHashCode()

Fungerar som standard-hash-funktion.

(Ärvd från Object)
GetType()

Hämtar den aktuella instansen Type .

(Ärvd från Object)
MemberwiseClone()

Skapar en ytlig kopia av den aktuella Object.

(Ärvd från Object)
ToString()

Returnerar en sträng som representerar det aktuella objektet.

(Ärvd från Object)

Gäller för