UserNamePasswordServiceCredential.UserNamePasswordValidationMode Property (System.ServiceModel.Security)

Switch View :
ScriptFree
.NET Framework Class Library
UserNamePasswordServiceCredential.UserNamePasswordValidationMode Property

Gets or sets the method of validating the user name and password.

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

Visual Basic
Public Property UserNamePasswordValidationMode As UserNamePasswordValidationMode
	Get
	Set
C#
public UserNamePasswordValidationMode UserNamePasswordValidationMode { get; set; }
Visual C++
public:
property UserNamePasswordValidationMode UserNamePasswordValidationMode {
	UserNamePasswordValidationMode get ();
	void set (UserNamePasswordValidationMode value);
}
F#
member UserNamePasswordValidationMode : UserNamePasswordValidationMode with get, set

Remarks

Possible values are:

If this property is set to Custom, the service uses the object returned by CustomUserNamePasswordValidator to validate user names and passwords in incoming messages.

Note Note

When a service is hosted in Internet Information Services (IIS) using transport-level security and the UserNamePasswordValidationMode property is set to Custom, the custom authentication scheme uses a subset of Windows authentication. That is because in this scenario, IIS performs Windows authentication prior to invoking the custom authenticator.

When the value of this property is set to MembershipProvider, specify the membership provider by setting the MembershipProvider property, and then the membership provider instance specified by the MembershipProvider property is used to validate the username and password in incoming messages.

Examples

The following example gets the value of this property.

Visual Basic

			' Create a service host.
			Dim httpUri As New Uri("http://localhost/Calculator")
			Dim sh As New ServiceHost(GetType(Calculator), httpUri)

			' Create a binding that uses a username/password credential.
			Dim b As New WSHttpBinding(SecurityMode.Message)
			b.Security.Message.ClientCredentialType = MessageCredentialType.UserName

			' Add an endpoint.
			sh.AddServiceEndpoint(GetType(ICalculator), b, "UserNamePasswordCalculator")

			' Get a reference to the UserNamePasswordServiceCredential object.
			Dim unpCredential As UserNamePasswordServiceCredential = sh.Credentials.UserNameAuthentication
			' Print out values.
			Console.WriteLine("IncludeWindowsGroup: {0}", unpCredential.IncludeWindowsGroups)
			Console.WriteLine("UserNamePasswordValidationMode: {0}", unpCredential.UserNamePasswordValidationMode)
			Console.WriteLine("CachedLogonTokenLifetime.Minutes: {0}", unpCredential.CachedLogonTokenLifetime.Minutes)
			Console.WriteLine("CacheLogonTokens: {0}", unpCredential.CacheLogonTokens)
			Console.WriteLine("MaxCachedLogonTokens: {0}", unpCredential.MaxCachedLogonTokens)

			Console.ReadLine()


C#

// Create a service host.
Uri httpUri = new Uri("http://localhost/Calculator");
ServiceHost sh = new ServiceHost(typeof(Calculator), httpUri);

// Create a binding that uses a username/password credential.
WSHttpBinding b = new WSHttpBinding(SecurityMode.Message);
b.Security.Message.ClientCredentialType = MessageCredentialType.UserName;

// Add an endpoint.
sh.AddServiceEndpoint(typeof(ICalculator), b, "UserNamePasswordCalculator");

// Get a reference to the UserNamePasswordServiceCredential object.
UserNamePasswordServiceCredential unpCredential = 
    sh.Credentials.UserNameAuthentication;
// Print out values.
Console.WriteLine("IncludeWindowsGroup: {0}", 
    unpCredential.IncludeWindowsGroups);
Console.WriteLine("UserNamePasswordValidationMode: {0}",
    unpCredential.UserNamePasswordValidationMode);
Console.WriteLine("CachedLogonTokenLifetime.Minutes: {0}",
    unpCredential.CachedLogonTokenLifetime.Minutes );
Console.WriteLine("CacheLogonTokens: {0}",
    unpCredential.CacheLogonTokens );
Console.WriteLine("MaxCachedLogonTokens: {0}",
    unpCredential.MaxCachedLogonTokens );

Console.ReadLine();


Version Information

.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Platforms

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.
See Also

Reference