This documentation is archived and is not being maintained.

LocalServiceSecuritySettings Class

Provides local service security properties that can be set.

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

public ref class LocalServiceSecuritySettings sealed

This class contains the local security settings used by the SecurityBindingElement to build the security channel. These settings are local to the service and are not represented in the service's security policy.

This example shows how to use the LocalServiceSecuritySettings class to change the DetectReplays setting.

    // Create an instance of the binding to use.
    WSHttpBinding b = new WSHttpBinding();

    // Get the binding element collection.
    BindingElementCollection bec = b.CreateBindingElements();

    // Find the SymmetricSecurityBindingElement in the colllection. 
    // Important: Cast to the SymmetricSecurityBindingElement when using the Find 
    // method.
    SymmetricSecurityBindingElement sbe = (SymmetricSecurityBindingElement)

    // Get the LocalServiceSettings from the binding element.
    LocalServiceSecuritySettings lss = sbe.LocalServiceSettings;

    // Print out values.
    Console.WriteLine("DetectReplays: {0} days", lss.DetectReplays);
    Console.WriteLine("ReplayWindow: {0} minutes", lss.ReplayWindow.Minutes);
    Console.WriteLine("MaxClockSkew: {0} minutes", lss.MaxClockSkew.Minutes);

    Console.WriteLine("Press Enter to Continue");
    // Change the MaxClockSkew to 3 minutes.
    lss.MaxClockSkew = new TimeSpan(0, 0, 3, 0);

    // Print the new value.
    Console.WriteLine("New MaxClockSkew: {0} minutes", lss.MaxClockSkew.Minutes);
    Console.WriteLine("Press Enter to End");

    // Create a URI for the service.
    Uri httpUri = new Uri("http://localhost/calculator");

    // Create a ServiceHost. The binding has the changed MaxClockSkew.
    ServiceHost sh = new ServiceHost(typeof(Calculator), httpUri);
    sh.AddServiceEndpoint(typeof(ICalculator), b, "");
    // sh.Open(); 
    // Console.WriteLine("Listening");
    // Console.ReadLine(); 
    // sh.Close();


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