ClientWindowsAuthenticationMembershipProvider.ValidateUser 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
使用操作系统提供的标识自动对当前用户进行身份验证。
public:
override bool ValidateUser(System::String ^ username, System::String ^ password);
public override bool ValidateUser (string username, string password);
override this.ValidateUser : string * string -> bool
Public Overrides Function ValidateUser (username As String, password As String) As Boolean
参数
返回
总是为 true
。
例外
示例
以下示例代码演示如何使用此方法通过 Windows 身份验证 对用户进行身份验证。
private bool ValidateUsingWindowsAuthentication()
{
ClientWindowsAuthenticationMembershipProvider authProvider =
System.Web.Security.Membership.Provider as
ClientWindowsAuthenticationMembershipProvider;
// Call ValidateUser and pass null values for the parameters.
// This call always returns true.
return authProvider.ValidateUser(null, null);
}
Private Function ValidateUsingWindowsAuthentication() As Boolean
Dim authProvider As ClientWindowsAuthenticationMembershipProvider = _
CType(System.Web.Security.Membership.Provider, _
ClientWindowsAuthenticationMembershipProvider)
' Call ValidateUser and pass Nothing for the parameters.
' This call always returns true.
Return authProvider.ValidateUser(Nothing, Nothing)
End Function
注解
将应用程序配置为使用 ClientWindowsAuthenticationMembershipProvider 类时, static
Membership.ValidateUser 方法将使用此方法实现。 方法 ClientWindowsAuthenticationMembershipProvider.ValidateUser 自动对当前用户进行身份验证, static
Thread.CurrentPrincipal 并将 属性设置为 ClientRolePrincipal 包含当前 WindowsIdentity的 对象。 ClientRoleProvider如果为应用程序配置了 ,则可以使用 ClientRolePrincipal 对象从角色服务中检索用户角色信息。
适用于
另请参阅
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈