UserNamePasswordServiceCredential 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
表示此类用于配置服务如何对使用用户名/密码身份验证的用户进行身份验证,并可用于配置登录令牌的缓存。
public ref class UserNamePasswordServiceCredential sealed
public sealed class UserNamePasswordServiceCredential
type UserNamePasswordServiceCredential = class
Public NotInheritable Class UserNamePasswordServiceCredential
- 继承
-
UserNamePasswordServiceCredential
示例
下面的示例输出服务的 UserNamePasswordServiceCredential 属性值。
// 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()
注解
如果没有配置服务所用的绑定,以进行基于用户名/密码的身份验证,则忽略此类的相关属性。 这些属性包括 CustomUserNamePasswordValidator、IncludeWindowsGroups、MembershipProvider 和 UserNamePasswordValidationMode 属性。
如果没有配置服务所用的绑定,以使用 Windows 用户名/密码身份验证,则忽略与登录令牌的缓存相关的设置。 这些设置包括 CachedLogonTokenLifetime、CacheLogonTokens 和 MaxCachedLogonTokens 属性。
属性
CachedLogonTokenLifetime |
获取或设置缓存令牌的最大时间长度。 |
CacheLogonTokens |
获取或设置一个值,该值指示是否缓存登录令牌。 |
CustomUserNamePasswordValidator |
获取或设置自定义用户名和密码验证程序。 |
IncludeWindowsGroups |
获取或设置一个值,该值指示 Windows 组是否包含在安全上下文中。 |
MaxCachedLogonTokens |
获取或设置要缓存的登录令牌的最大数目。 |
MembershipProvider |
获取或设置成员资格提供程序。 |
UserNamePasswordValidationMode |
获取或设置验证用户名和密码的方法。 |
方法
Equals(Object) |
确定指定对象是否等于当前对象。 (继承自 Object) |
GetHashCode() |
作为默认哈希函数。 (继承自 Object) |
GetType() |
获取当前实例的 Type。 (继承自 Object) |
MemberwiseClone() |
创建当前 Object 的浅表副本。 (继承自 Object) |
ToString() |
返回表示当前对象的字符串。 (继承自 Object) |