WindowsClientCredential.AllowedImpersonationLevel Property


Gets or sets the allowed impersonation level.

Namespace:   System.ServiceModel.Security
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

Public Property AllowedImpersonationLevel As TokenImpersonationLevel

This property specifies the impersonation level granted by the client to the server when using Windows SSPI Negotiate authentication. Note that the impersonation level obtained by the server when it impersonates the client token is not solely a function of this setting. It is also a function of the associated privileges and domain settings for the account in which the service is running.

The client must explicitly set the allowed impersonation level using this property.

When the client specifies anonymous impersonation the client always authenticates to the service as anonymous even when no impersonation is performed on the service. This is due to underlying Windows operating system behavior.

For more information about Windows impersonation, go to Impersonating and Reverting. For more information about impersonation using Windows Communication Foundation (WCF), see Delegation and Impersonation with WCF.

The following example shows how to set this property.

' Create a service host.
Dim ea As New EndpointAddress("http://localhost/Calculator")
Dim b As New WSHttpBinding(SecurityMode.Message)
b.Security.Message.ClientCredentialType = _

' 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}", _
Console.WriteLine("AllowNtlm: {0}", winCred.AllowNtlm)
Console.WriteLine("Domain: {0}", winCred.ClientCredential.Domain)

' Change the AllowedImpersonationLevel.
winCred.AllowedImpersonationLevel = _

Console.WriteLine("Changed AllowedImpersonationLevel: {0}", _
' Open the calculator and use it.
' cc.Open()
' Console.WriteLine(cc.Add(11, 11))
' Close the client.
' cc.Close()

Universal Windows Platform
Available since 8
.NET Framework
Available since 3.0
Portable Class Library
Supported in: portable .NET platforms
Return to top