Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

BasicHttpMessageCredentialType Enumeration

Enumerates credential types the client can authenticate with when security is enabled in the BasicHttpBinding binding.

Namespace:  System.ServiceModel
Assembly:  System.ServiceModel (in System.ServiceModel.dll)
public enum BasicHttpMessageCredentialType
Member nameDescription
UserNameIndicates that the client be authenticated using a username credential.
CertificateIndicates that a client be authenticated using a certificate.

If Mode is configured to perform client authentication at the message level, this enumeration controls the client credential type. Both username and X.509 certificate to use must be provisioned through an IEndpointBehavior instance which implements the SecurityCredentialsManager extensibility point; in a common default case this is ClientCredentials.

The client credential in the certificate case must be specified using the ClientCertificate property of the ClientCredentials class.

The client credential in the username case must be specified using the UserName property of the ClientCredentials class.

In addition, when message security mode is used, the client must be provisioned with the service's certificate. The service credential in this case must be specified using the ServiceCertificate property on the ClientCredentials class.

The following configuration file snippets illustrates how to specify BasicHttpMessageCredentialType:

<configuration>
  <system.serviceModel>
    <services>
      <service name="Microsoft.ServiceModel.Samples.CalculatorService"
               behaviorConfiguration="CalculatorServiceBehavior">
        <!-- use base address provided by host -->
        <endpoint address=""
                  binding="basicHttpBinding"
                  bindingConfiguration="Binding1" 
                  contract="Microsoft.ServiceModel.Samples.ICalculator" />
        <endpoint contract="IMetadataExchange"
                  binding="mexHttpBinding"
                  address="mex" />
      </service>
    </services>

    <bindings>
      <basicHttpBinding>
        <binding name="Binding1" >
          <security mode = "Message">
            <message clientCredentialType="Certificate"/>
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>

    <behaviors>
      <serviceBehaviors>
        <behavior name="CalculatorServiceBehavior">
          <serviceDebug includeExceptionDetailInFaults="false" />
          <serviceMetadata httpGetEnabled="true" />
          <serviceCredentials>
            <serviceCertificate findValue="localhost" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />
            <clientCertificate>
              <authentication certificateValidationMode="PeerOrChainTrust" />
            </clientCertificate>
          </serviceCredentials>
        </behavior>
      </serviceBehaviors>
    </behaviors>

  </system.serviceModel>
</configuration>

The important sections are:

The bindings section where we specify the security mode (Message) and the type of credential that will be used to authenticate the client:

<bindings>
  <basicHttpBinding>
    <binding name="Binding1" >
      <security mode = "Message">
        <message clientCredentialType="Certificate"/>
      </security>
    </binding>
  </basicHttpBinding>
</bindings>

The behaviors section where we specify the certificate to use for service authentication and the method for validating the client certificate:

<behaviors>
  <serviceBehaviors>
    <behavior name="CalculatorServiceBehavior">
      <serviceDebug includeExceptionDetailInFaults="false" />
      <serviceMetadata httpGetEnabled="true" />
      <serviceCredentials>
        <serviceCertificate findValue="localhost" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />
        <clientCertificate>
          <authentication certificateValidationMode="PeerOrChainTrust" />
        </clientCertificate>
      </serviceCredentials>
    </behavior>
  </serviceBehaviors>
</behaviors>

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.