ClientFormsAuthenticationMembershipProvider.ValidateUser 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정된 자격 증명을 사용하여 사용자를 인증합니다.
오버로드
ValidateUser(String, String) |
지정된 사용자 이름 및 암호를 사용하여 사용자를 인증합니다. |
ValidateUser(String, String, Boolean) |
지정된 사용자 이름 및 암호를 사용하여 사용자를 인증하고, 선택적으로 암호 해시를 로컬 데이터 캐시에 저장합니다. |
ValidateUser(String, String, String) |
지정된 사용자 이름 및 암호를 사용하여 지정된 서비스 URI에서 사용자를 인증합니다. |
ValidateUser(String, String)
지정된 사용자 이름 및 암호를 사용하여 사용자를 인증합니다.
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
매개 변수
- username
- String
인증할 사용자의 이름이거나 이 애플리케이션에서 사용하도록 구성된 Empty 구현에서 자격 증명을 검색하려는 경우 IClientFormsAuthenticationCredentialsProvider 또는 null
입니다.
- password
- String
인증할 사용자의 암호입니다.
반환
사용자가 인증되었으면 true
이고, 그렇지 않으면 false
입니다.
예외
IsOffline 속성 값이 false
인데 멤버 자격 공급자가 인증 서비스에 액세스할 수 없는 경우
예제
다음 예제 코드에는이 메서드를 사용 하 여 사용자 유효성 검사를 사용 하는 방법을 보여 줍니다.는 IClientFormsAuthenticationCredentialsProvider 구현 합니다. 이 예제에서는 자격 증명 공급자를 사용 하도록 애플리케이션을 구성할 수 있습니다.
private bool ValidateUsingCredentialsProvider()
{
bool isAuthorized = false;
try
{
ClientFormsAuthenticationMembershipProvider authProvider =
System.Web.Security.Membership.Provider as
ClientFormsAuthenticationMembershipProvider;
// Call ValidateUser with empty strings in order to display the
// login dialog box configured as a credentials provider.
isAuthorized = authProvider.ValidateUser(String.Empty, String.Empty);
}
catch (System.Net.WebException)
{
MessageBox.Show("Unable to access the authentication service.",
"Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
if (!isAuthorized)
{
MessageBox.Show("Unable to authenticate.", "Not logged in",
MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit();
}
return isAuthorized;
}
Private Function ValidateUsingCredentialsProvider() As Boolean
Dim isAuthorized As Boolean = False
Try
Dim authProvider As ClientFormsAuthenticationMembershipProvider = _
CType(System.Web.Security.Membership.Provider, _
ClientFormsAuthenticationMembershipProvider)
' Call ValidateUser with empty strings in order to display the
' login dialog box configured as a credentials provider.
isAuthorized = authProvider.ValidateUser(String.Empty, String.Empty)
Catch ex As System.Net.WebException
MessageBox.Show("Unable to access the authentication service.", _
"Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End Try
If Not isAuthorized Then
MessageBox.Show("Unable to authenticate.", "Not logged in", _
MessageBoxButtons.OK, MessageBoxIcon.Error)
Application.Exit()
End If
Return isAuthorized
End Function
설명
폼 인증을 사용 하 여 확인 하므로 사용자가 클라이언트 애플리케이션 서비스를 사용할 수 있습니다. 사용자 확인을 위해 일반적으로 호출 합니다 static
Membership.ValidateUser 내부적으로 호출 하는 메서드를 ClientFormsAuthenticationMembershipProvider.ValidateUser 메서드. 또는 직접 호출할 수 있습니다이 메서드를 예제 단원에 나와 있는 것 처럼 합니다.
폼 인증 사용자 지정 애플리케이션에서 제공 하는 로그인 컨트롤을 통해 증명은 필요 합니다. 자격 증명을 검색 하 고 전달할 수는 Membership.ValidateUser 메서드. 빈 문자열에 전달할 수 있습니다 또는 null
자격 증명 공급자를 사용 하도록 합니다.
추가 정보
- IClientFormsAuthenticationCredentialsProvider
- ValidateUser(String, String)
- 클라이언트 애플리케이션 서비스
- 방법: 클라이언트 애플리케이션 서비스 구성
- 방법: 사용자 로그인 및 클라이언트 애플리케이션 서비스를 사용 하 여 로그 아웃 구현
적용 대상
ValidateUser(String, String, Boolean)
지정된 사용자 이름 및 암호를 사용하여 사용자를 인증하고, 선택적으로 암호 해시를 로컬 데이터 캐시에 저장합니다.
public:
bool ValidateUser(System::String ^ username, System::String ^ password, bool rememberMe);
public bool ValidateUser (string username, string password, bool rememberMe);
override this.ValidateUser : string * string * bool -> bool
Public Function ValidateUser (username As String, password As String, rememberMe As Boolean) As Boolean
매개 변수
- username
- String
인증할 사용자의 이름입니다.
- password
- String
인증할 사용자의 암호입니다.
- rememberMe
- Boolean
오프라인 사용자 및 사용자 인증 쿠키가 만료된 경우 자동 재인증에 사용할 수 있도록 암호 해시를 로컬 데이터 캐시에 저장하려는 경우 true
이고, 쿠키가 만료된 경우 사용자가 직접 재인증을 수행하도록 하려는 경우에는 false
입니다.
반환
사용자가 인증되었으면 true
이고, 그렇지 않으면 false
입니다.
예외
IsOffline 속성 값이 false
인데 멤버 자격 공급자가 인증 서비스에 액세스할 수 없는 경우
예제
다음 예제 코드에서는이 메서드를 사용 하 여 애플리케이션 코드에서 로그인 컨트롤을 사용 하 여 사용자 유효성을 검사 하는 방법에 설명 합니다. 이 예제는 TextBox 라는 컨트롤 usernameTextBox
, TextBox 이라는 컨트롤이 passwordTextBox
, 및 CheckBox 라는 컨트롤 rememberMeCheckBox
합니다.
private bool ValidateUsingLoginControls()
{
bool isAuthorized = false;
try
{
ClientFormsAuthenticationMembershipProvider authProvider =
System.Web.Security.Membership.Provider as
ClientFormsAuthenticationMembershipProvider;
// Call ValidateUser with credentials retrieved from login controls.
isAuthorized = authProvider.ValidateUser(usernameTextBox.Text,
passwordTextBox.Text, rememberMeCheckBox.Checked);
}
catch (System.Net.WebException)
{
MessageBox.Show("Unable to access the authentication service.",
"Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
if (!isAuthorized)
{
MessageBox.Show("Unable to authenticate.", "Not logged in",
MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit();
}
return isAuthorized;
}
Private Function ValidateUsingLoginControls() As Boolean
Dim isAuthorized As Boolean = False
Try
Dim authProvider As ClientFormsAuthenticationMembershipProvider = _
CType(System.Web.Security.Membership.Provider, _
ClientFormsAuthenticationMembershipProvider)
' Call ValidateUser with credentials retrieved from login controls.
isAuthorized = authProvider.ValidateUser(usernameTextBox.Text, _
passwordTextBox.Text, rememberMeCheckBox.Checked)
Catch ex As System.Net.WebException
MessageBox.Show("Unable to access the authentication service.", _
"Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End Try
If Not isAuthorized Then
MessageBox.Show("Unable to authenticate.", "Not logged in", _
MessageBoxButtons.OK, MessageBoxIcon.Error)
Application.Exit()
End If
Return isAuthorized
End Function
설명
폼 인증을 사용 하 여 확인 하므로 사용자가 클라이언트 애플리케이션 서비스를 사용할 수 있습니다. 사용자 확인을 위해 일반적으로 호출 합니다 static
Membership.ValidateUser 내부적으로 호출 하는 메서드를 ClientFormsAuthenticationMembershipProvider.ValidateUser(String, String) 메서드. 호출할 수 있습니다는 ClientFormsAuthenticationMembershipProvider.ValidateUser 메서드를 직접. 전달이 오버 로드를 호출할 수 있습니다는 rememberMe
외에 값을 username
및 password
값입니다.
추가 정보
- ValidateUser(String, String)
- 클라이언트 애플리케이션 서비스
- 방법: 클라이언트 애플리케이션 서비스 구성
- 방법: 사용자 로그인 및 클라이언트 애플리케이션 서비스를 사용 하 여 로그 아웃 구현
적용 대상
ValidateUser(String, String, String)
지정된 사용자 이름 및 암호를 사용하여 지정된 서비스 URI에서 사용자를 인증합니다.
public:
static bool ValidateUser(System::String ^ username, System::String ^ password, System::String ^ serviceUri);
public static bool ValidateUser (string username, string password, string serviceUri);
static member ValidateUser : string * string * string -> bool
Public Shared Function ValidateUser (username As String, password As String, serviceUri As String) As Boolean
매개 변수
- username
- String
인증할 사용자의 이름입니다.
- password
- String
인증할 사용자의 암호입니다.
- serviceUri
- String
사용할 인증 서비스의 URI입니다.
반환
사용자가 인증되었으면 true
이고, 그렇지 않으면 false
입니다.
예외
IsOffline 속성 값이 false
인데 멤버 자격 공급자가 인증 서비스에 액세스할 수 없는 경우
예제
다음 예제 코드에서는이 메서드를 사용 하 여 지정된 된 위치에서 인증 서비스를 통해 사용자의 유효성을 검사 하는 방법에 설명 합니다. 사용자 자격 증명을 애플리케이션 코드에서 로그인 컨트롤에서 검색 됩니다. 이 예제는 TextBox 라는 컨트롤 usernameTextBox
와 TextBox 라는 컨트롤 passwordTextBox
합니다.
private bool ValidateUsingServiceUri(String serviceUri)
{
bool isAuthorized = false;
try
{
// Call the static overload of ValidateUser. Specify credentials
// retrieved from login controls and the service location.
isAuthorized =
ClientFormsAuthenticationMembershipProvider.ValidateUser(
usernameTextBox.Text, passwordTextBox.Text, serviceUri);
}
catch (System.Net.WebException)
{
MessageBox.Show("Unable to access the authentication service.",
"Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
if (!isAuthorized)
{
MessageBox.Show("Unable to authenticate.", "Not logged in",
MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit();
}
return isAuthorized;
}
Private Function ValidateUsingServiceUri(ByVal serviceUri As String) As Boolean
Dim isAuthorized As Boolean = False
Try
' Call the Shared overload of ValidateUser. Specify credentials
' retrieved from login controls and the service location.
isAuthorized = _
ClientFormsAuthenticationMembershipProvider.ValidateUser( _
usernameTextBox.Text, passwordTextBox.Text, serviceUri)
Catch ex As System.Net.WebException
MessageBox.Show("Unable to access the authentication service.", _
"Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End Try
If Not isAuthorized Then
MessageBox.Show("Unable to authenticate.", "Not logged in", _
MessageBoxButtons.OK, MessageBoxIcon.Error)
Application.Exit()
End If
Return isAuthorized
End Function
설명
폼 인증을 사용 하 여 확인 하므로 사용자가 클라이언트 애플리케이션 서비스를 사용할 수 있습니다. 사용자 확인을 위해 일반적으로 호출 합니다 static
Membership.ValidateUser 내부적으로 호출 하는 메서드를 ClientFormsAuthenticationMembershipProvider.ValidateUser 메서드. 호출할 수 있습니다는 ClientFormsAuthenticationMembershipProvider.ValidateUser 메서드를 직접. 지정 된 위치에서 인증 서비스에 액세스 하려면이 오버 로드를 호출할 수는 serviceUri
매개 변수입니다. 이 오버 로드를 사용 하는 대신 설정 합니다 ServiceUri 속성과 호출은 ValidateUser(String, String) 오버 로드.
추가 정보
- ValidateUser(String, String)
- 클라이언트 애플리케이션 서비스
- 방법: 클라이언트 애플리케이션 서비스 구성
- 방법: 사용자 로그인 및 클라이언트 애플리케이션 서비스를 사용 하 여 로그 아웃 구현
적용 대상
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기