Export (0) Print
Expand All

How to: Specify the Client Credential Type

After setting a security mode (either transport or message), you have the option of setting the client credential type. This property specifies what type of credential the client must provide to the service for authentication. For more information about setting the security mode (a necessary step before setting the client credential type), see How to: Set the Security Mode.

To set the client credential type in code

  1. Create an instance of the binding that the service will use. This example uses the WSHttpBinding binding.

  2. Set the Mode property to an appropriate value. This example uses the Message mode.

  3. Set the ClientCredentialType property to an appropriate value. This example sets it to use Windows authentication (Windows).

    ServiceHost myServiceHost = new ServiceHost(typeof(CalculatorService));
    // Create a binding to use.
    WSHttpBinding binding = new WSHttpBinding();
    binding.Security.Mode = SecurityMode.Message;
    binding.Security.Message.ClientCredentialType =
        MessageCredentialType.Windows;
    
    

To set the client credential type in configuration

  1. Add a <system.ServiceModel> element to the configuration file.

  2. As a child element, add a <bindings> element.

  3. Add an appropriate binding. This example uses the <wsHttpBinding> element.

  4. Add a <binding> element and set the name attribute to an appropriate value. This example uses the name "SecureBinding".

  5. Add a <security> binding. Set the mode attribute to an appropriate value. This example sets it to "Message".

  6. Add either a <message> or <transport> element, as determined by the security mode. Set the clientCredentialType attribute to an appropriate value. This example uses "Windows".

    <system.serviceModel>
      <bindings>
        <wsHttpBinding>
          <binding name="SecureBinding">
            <security mode="Message">
                 <message clientCredentialType="Windows" />
             </security>
          </binding>
        </wsHttpBinding>
      </bindings>
    </system.serviceModel>
    

See Also

Community Additions

ADD
Show:
© 2014 Microsoft