Export (0) Print
Expand All

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)

'Declaration
Public NotInheritable Class NetTcpSecurity
'Usage
Dim instance As NetTcpSecurity

public final class NetTcpSecurity
public final class NetTcpSecurity
Not applicable.

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 Windows Communication Foundation (WCF) 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 runtime communication stack supporting 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. Since this property is read-only you will not be able to 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 illustrates how to retrieve the NetTcpSecurity object from a NetTcpBinding and prints out the various settings it contains:

using (ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService)))
{
    serviceHost.Open();
    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("\tMessageSecurityOverTcp:");
    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("\tTcpTransportSecurity:");
    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.");
    Console.WriteLine();
    Console.ReadLine();
}

System.Object
  System.ServiceModel.NetTcpSecurity

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 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft