ClientCredentials Class

Enables the user to configure client and service credentials as well as service credential authentication settings for use on the client side of communication.

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

public class ClientCredentials extends SecurityCredentialsManager implements IEndpointBehavior

The ClientCredentials is accessed through the ClientCredentials property of the ClientBase(TChannel) class.

A ClientCredentials object is added to the Behaviors collection. The ClientCredentials property is a Façade (a well-known design pattern) over an entry in that collection. Many properties in this class return objects that consist mainly of properties. These objects can be used for configuration: once you get the object, you can use it to set properties by calling its members.

The following code sample shows how to override this class and implement your own custom client credentials that includes a custom security token manager.

public class MyClientCredentials : ClientCredentials
{
    string creditCardNumber;

    public MyClientCredentials()
    {
        // Perform client credentials initialization.
    }

    protected MyClientCredentials(MyClientCredentials other)
        : base(other)
    {
        // Clone fields defined in this class. 
        this.creditCardNumber = other.creditCardNumber;
    }

    public string CreditCardNumber
    {
        get
        {
            return this.creditCardNumber;
        }
        set
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            this.creditCardNumber = value;
        }
    }

    public override SecurityTokenManager CreateSecurityTokenManager()
    {
        // Return your implementation of the SecurityTokenManager. 
        return new MyClientCredentialsSecurityTokenManager(this);
    }

    protected override ClientCredentials CloneCore()
    {
        // Implement the cloning functionality. 
        return new MyClientCredentials(this);
    }
}

System.Object
  System.ServiceModel.Security.SecurityCredentialsManager
    System.ServiceModel.Description.ClientCredentials

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC

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

.NET Compact Framework

Supported in: 3.5
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft