This documentation is archived and is not being maintained.

NetTcpSecurity Class

Specifies the types of transport-level and message-level security used by an endpoint configured with a NetTcpBinding.


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

public sealed class NetTcpSecurity

The NetTcpSecurity type exposes the following members.

Public methodNetTcpSecurityInitializes a new instance of the NetTcpSecurity class.

Public propertyMessageGets the type of message-level security requirements for a service configured with a NetTcpBinding.
Public propertyModeGets or sets whether message-level security and transport-level security are used by an endpoint configured with a NetTcpBinding.
Public propertyTransportGets the type of message-level security requirements for an endpoint configured with a NetTcpBinding.

Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)

Each of the standard bindings provides parameters for controlling the transfer security requirements. These parameters typically include the security mode that specified whether message-level or transport-level security is used and the choice of client credential type. Based on the choice of options these parameters present, a channel stack is constructed with appropriate security.

The system-provided bindings supplied by are a set designed to meet some of the most common scenario requirements. Each of these bindings allows the specification of security requirements for some specific targeted scenarios.

NetTcpSecurity provides the security specifications for NetTcpBinding. This is a secure, reliable, optimized binding suitable for cross-machine communication. By default it generates a run-time communication stack that supports TCP for message delivery and Windows Security for message security and authentication, WS-ReliableMessaging for reliability, and binary message encoding.

This class is instantiated by the NetTcpBinding, and can be accessed by a read-only property called Security. Because this property is read-only you cannot make changes to the returned object. If you want to control the creation of the NetTcpSecurity object, you can derive a class from NetTcpBinding.

The following code shows how to retrieve the NetTcpSecurity object from a NetTcpBinding and prints out the various settings it contains:

using (ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService)))
    ServiceEndpointCollection endpoints = serviceHost.Description.Endpoints;
    ServiceEndpoint endpoint = endpoints.Find(typeof(ICalculator));

    NetTcpBinding binding = (NetTcpBinding) endpoint.Binding;

    NetTcpSecurity security = binding.Security;
    MessageSecurityOverTcp msTcp = security.Message;

    Console.WriteLine("Dumping NetTcpSecurity object:");
    Console.WriteLine("\t\tAlgorithm Suite: {0}", msTcp.AlgorithmSuite);
    Console.WriteLine("\t\tClient Credential Type: {0}", msTcp.ClientCredentialType);

    Console.WriteLine("\tSecurity Mode: {0}", security.Mode);

    TcpTransportSecurity tsTcp = security.Transport;
    Console.WriteLine("\t\tClient Credential Type: {0}", tsTcp.ClientCredentialType);
    Console.WriteLine("\t\tProtectionLevel: {0}", tsTcp.ProtectionLevel);

    // The service can now be accessed.
    Console.WriteLine("The service is ready.");
    Console.WriteLine("Press <ENTER> to terminate service.");

.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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

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