Export (0) Print
Expand All

WindowsClientCredential.AllowedImpersonationLevel Property

Gets or sets the allowed impersonation level.

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

public TokenImpersonationLevel AllowedImpersonationLevel { get; set; }
/** @property */
public TokenImpersonationLevel get_AllowedImpersonationLevel ()

/** @property */
public void set_AllowedImpersonationLevel (TokenImpersonationLevel value)

public function get AllowedImpersonationLevel () : TokenImpersonationLevel

public function set AllowedImpersonationLevel (value : TokenImpersonationLevel)

Not applicable.

Property Value

One of the TokenImpersonationLevel values.

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 will always authenticate 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 on 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.
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();

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft