WindowsClientCredential.AllowedImpersonationLevel Eigenschaft

Definition

Dient zum Abrufen oder Festlegen der zulässigen Identitätswechselebene.

public:
 property System::Security::Principal::TokenImpersonationLevel AllowedImpersonationLevel { System::Security::Principal::TokenImpersonationLevel get(); void set(System::Security::Principal::TokenImpersonationLevel value); };
public System.Security.Principal.TokenImpersonationLevel AllowedImpersonationLevel { get; set; }
member this.AllowedImpersonationLevel : System.Security.Principal.TokenImpersonationLevel with get, set
Public Property AllowedImpersonationLevel As TokenImpersonationLevel

Eigenschaftswert

Einer der TokenImpersonationLevel Werte.

Beispiele

Das folgende Beispiel zeigt, wie Diese Eigenschaft festgelegt wird.

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

Hinweise

Diese Eigenschaft gibt die Identitätswechselebene an, die vom Client beim Verwenden Windows SSPI Negotiate-Authentifizierung vom Client gewährt wird. Beachten Sie, dass die identitätswechselebene, die vom Server abgerufen wird, wenn sie den Identitätswechsel des Clienttokens angibt, nicht nur eine Funktion dieser Einstellung ist. Es ist auch eine Funktion der zugehörigen Berechtigungen und Domäneneinstellungen für das Konto, in dem der Dienst ausgeführt wird.

Der Client muss die zulässige Identitätswechselebene explizit mithilfe dieser Eigenschaft festlegen.

Wenn der Client anonymen Identitätswechsel angibt, authentifiziert sich der Client immer als anonym, selbst wenn kein Identitätswechsel für den Dienst ausgeführt wird. Dies liegt an zugrunde liegenden Windows Betriebssystemverhaltens.

Weitere Informationen zum identitätswechselnden Windows wechseln Sie zu Impersonating and Reverting. Weitere Informationen zum Identitätswechsel mithilfe von Windows Communication Foundation finden Sie unter Delegation und Identitätswechsel.

Gilt für: