UserNamePasswordServiceCredential Class
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Represents a class that is used to configure how the service authenticates users that use user name/password authentication and to configure the caching of logon tokens.
public ref class UserNamePasswordServiceCredential sealed
public sealed class UserNamePasswordServiceCredential
type UserNamePasswordServiceCredential = class
Public NotInheritable Class UserNamePasswordServiceCredential
- Inheritance
-
UserNamePasswordServiceCredential
The following example prints the values of the UserNamePasswordServiceCredential properties for a service.
// 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();
' 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()
If none of the bindings used by a service is configured for user name/password-based authentication, the relevant properties for this class are ignored. These properties include the CustomUserNamePasswordValidator, IncludeWindowsGroups, MembershipProvider, and UserNamePasswordValidationMode properties.
If none of the bindings used by a service is configured to use Windows authentication for user name/password, the settings related to caching of logon tokens are ignored. These settings include the CachedLogonTokenLifetime, CacheLogonTokens, and MaxCachedLogonTokens properties.
Cached |
Gets or sets the maximum length of time that a token is cached. |
Cache |
Gets or sets a value that indicates whether logon tokens are cached. |
Custom |
Gets or sets a custom user name and password validator. |
Include |
Gets or sets a value that indicates whether Windows groups are included in the security context. |
Max |
Gets or sets the maximum number of logon tokens to cache. |
Membership |
Gets or sets the membership provider. |
User |
Gets or sets the method of validating the user name and password. |
Equals(Object) |
Determines whether the specified object is equal to the current object. (Inherited from Object) |
Get |
Serves as the default hash function. (Inherited from Object) |
Get |
Gets the Type of the current instance. (Inherited from Object) |
Memberwise |
Creates a shallow copy of the current Object. (Inherited from Object) |
To |
Returns a string that represents the current object. (Inherited from Object) |
Product | Versions |
---|---|
.NET Framework | 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: