Gets or sets the method of validating the user name and password.
Assembly: System.ServiceModel (in System.ServiceModel.dll)
Public Property UserNamePasswordValidationMode As UserNamePasswordValidationMode Get Set
public UserNamePasswordValidationMode UserNamePasswordValidationMode { get; set; }
public: property UserNamePasswordValidationMode UserNamePasswordValidationMode { UserNamePasswordValidationMode get (); void set (UserNamePasswordValidationMode value); }
member UserNamePasswordValidationMode : UserNamePasswordValidationMode with get, set
Property Value
Type: System.ServiceModel.Security.UserNamePasswordValidationModeA value from the enumeration in UserNamePasswordValidationMode.
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
|
|---|
|
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.
The following example gets the value of this property.
' 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()
// 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();
.NET Framework
Supported in: 4, 3.5, 3.0.NET Framework Client Profile
Supported in: 4, 3.5 SP1Windows 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.
Note