ClientFormsIdentity 클래스

정의

폼 인증을 사용하여 클라이언트 애플리케이션 서비스에 대해 인증된 사용자의 ID를 나타냅니다.

public ref class ClientFormsIdentity : IDisposable, System::Security::Principal::IIdentity
public class ClientFormsIdentity : IDisposable, System.Security.Principal.IIdentity
type ClientFormsIdentity = class
    interface IIdentity
    interface IDisposable
Public Class ClientFormsIdentity
Implements IDisposable, IIdentity
상속
ClientFormsIdentity
구현

예제

다음 예제 코드에서는이 클래스를 사용 하 여 애플리케이션을 오프 라인 상태로 유지 하는 경우 사용자를 자동으로 유효성 검사를 하는 방법에 설명 합니다. 이 예제는 CheckedChanged 확인란 값과 일치 하도록 오프 라인 상태를 업데이트 하는 이벤트 처리기입니다. 애플리케이션을 온라인 상태로 설정 하는 사용자, 이벤트 처리기를 호출 하 여 사용자 유효성 검사를 다시 시도 RevalidateUser 메서드. 그러나 인증 서버를 사용할 수 없는 경우 이벤트 처리기에 애플리케이션을 오프 라인 상태로 반환 합니다.

참고

RevalidateUser 메서드는 편의상의 목적으로만 사용됩니다. 반환 값이 없기 때문에 유효성 재검사가 실패했는지 여부를 나타낼 수 없습니다. 예를 들어 서버에서 사용자 자격 증명이 변경된 경우 유효성 재검사가 실패할 수 있습니다. 이 경우 서비스 호출이 실패한 후 명시적으로 사용자의 유효성을 검사하는 코드를 포함하는 것이 좋습니다. 자세한 내용은 웹 설정 액세스 섹션을 참조 하세요 연습: 클라이언트 애플리케이션 서비스를 사용 하 여입니다.

private void workOfflineCheckBox_CheckedChanged(
    object sender, EventArgs e)
{
    ConnectivityStatus.IsOffline = workOfflineCheckBox.Checked;
    if (!ConnectivityStatus.IsOffline)
    {
        try
        {
            // Silently re-validate the user.
            ((ClientFormsIdentity)
                System.Threading.Thread.CurrentPrincipal.Identity)
                .RevalidateUser();

            // If any settings have been changed locally, save the new
            // new values to the Web settings service.
            SaveSettings();

            // If any settings have not been changed locally, check 
            // the Web settings service for updates. 
            Properties.Settings.Default.Reload();
        }
        catch (System.Net.WebException)
        {
            MessageBox.Show(
                "Unable to access the authentication service. " +
                Environment.NewLine + "Staying in offline mode.",
                "Warning", MessageBoxButtons.OK, 
                MessageBoxIcon.Warning);
            workOfflineCheckBox.Checked = true;
        }
    }
}
Private Sub workOfflineCheckBox_CheckedChanged( _
    ByVal sender As Object, ByVal e As EventArgs) _
    Handles workOfflineCheckBox.CheckedChanged

    ConnectivityStatus.IsOffline = workOfflineCheckBox.Checked
    If Not ConnectivityStatus.IsOffline Then

        Try

            ' Silently re-validate the user.
            CType(System.Threading.Thread.CurrentPrincipal.Identity,  _
                ClientFormsIdentity).RevalidateUser()

            ' If any settings have been changed locally, save the new
            ' new values to the Web settings service.
            SaveSettings()

            ' If any settings have not been changed locally, check 
            ' the Web settings service for updates. 
            My.Settings.Reload()

        Catch ex As System.Net.WebException

            MessageBox.Show( _
                "Unable to access the authentication service. " & _
                Environment.NewLine + "Staying in offline mode.", _
                "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
            workOfflineCheckBox.Checked = True

        End Try

    End If
End Sub

설명

클라이언트 애플리케이션 서비스 기능은이 클래스를 사용 하 여 인증 된 사용자를 나타냅니다. 클라이언트 애플리케이션 서비스 및 폼 인증을 사용 하도록 애플리케이션을 구성할 때 호출 하 여 사용자를 인증할 수 있습니다 합니다 staticMembership.ValidateUser 메서드. 인증 후 현재에 대 한 참조를 검색할 수 있습니다 ClientFormsIdentity 통해 인스턴스를 Identity 의 속성을 IPrincipal 검색할를 staticThread.CurrentPrincipal 속성. 자세한 내용은 클라이언트 애플리케이션 서비스를 참조하세요.

일반적으로 액세스 한 ClientFormsIdentity 개체는 IIdentity 이 클래스에 대 한 직접 종속성을 방지 하기 위해 참조 합니다. 확인 하 여 사용자가 인증 되었는지 여부를 확인할 수 있습니다는 IIdentity.IsAuthenticated id의 속성입니다. 그러나 클라이언트 애플리케이션 서비스 아니라, Windows에 대 한 사용자를 인증할 수 있습니다. 클라이언트 애플리케이션 서비스에 대 한 사용자가 인증 되었는지 여부를 확인 하려면도 확인 해야 하는 IIdentity.AuthenticationType 속성 값이 "ClientForms"입니다.

명시적 사용 해야 합니다 ClientFormsIdentity 호출에 대 한 참조를 RevalidateUser 에서 정의 되지 않은 메서드는 IIdentity 인터페이스입니다.

생성자

ClientFormsIdentity(String, String, MembershipProvider, String, Boolean, CookieContainer)

ClientFormsIdentity 클래스의 새 인스턴스를 초기화합니다.

속성

AuthenticationCookies

인증 서비스에서 검색된 쿠키의 컬렉션을 가져옵니다.

AuthenticationType

사용자를 인증하는 데 사용되는 인증 형식을 가져옵니다.

IsAuthenticated

사용자가 인증되었는지 여부를 나타내는 값을 가져옵니다.

Name

사용자 이름을 가져옵니다.

Provider

사용자를 인증하는 데 사용되는 멤버 자격 공급자를 가져옵니다.

메서드

Dispose()

ClientFormsIdentity에서 사용하는 모든 리소스를 해제합니다.

Dispose(Boolean)

ClientFormsIdentity에서 사용하는 관리되지 않는 리소스를 해제하고, 관리되는 리소스를 선택적으로 해제할 수 있습니다.

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
RevalidateUser()

캐시된 자격 증명을 사용하여 자동으로 사용자를 인증합니다.

ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상

추가 정보