ClientCredentials.Windows Property

Definition

Gets an object used to control the Windows credential that the client uses to authenticate itself to the service.

public System.ServiceModel.Security.WindowsClientCredential Windows { get; }

Property Value

A WindowsClientCredential that represents the current Windows credential.

Examples

The following code shows how to use the object returned by this property to configure the impersonation level.

  // Create a client object with the given client endpoint configuration.
 CalculatorClient client = new CalculatorClient();
try
  {
      client.ClientCredentials.Windows.AllowedImpersonationLevel
          = TokenImpersonationLevel.Impersonation;
  }
  catch (TimeoutException timeProblem)
  {
    Console.WriteLine("The service operation timed out. " + timeProblem.Message);
    Console.ReadLine();
    client.Abort();
  }
  catch (CommunicationException commProblem)
  {
    Console.WriteLine("There was a communication problem. " + commProblem.Message + commProblem.StackTrace);
    Console.ReadLine();
    client.Abort();
  }

Remarks

You can use the object returned by this property to configure the Windows credential by calling its members, such as AllowNtlm and AllowedImpersonationLevel.

These settings control the Windows credential used during SPNEGO negotiation at either the message or transport level or the properties of Kerberos tokens used for authentication at the message level.

Applies to

منتج الإصدارات
.NET Core 1.0, Core 1.1, 8 (package-provided)
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
UWP 10.0