ClientFormsAuthenticationMembershipProvider.Logout 메서드

정의

사용자를 로그아웃합니다.

public:
 void Logout();
public void Logout ();
member this.Logout : unit -> unit
Public Sub Logout ()

예외

IsOffline 속성 값이 false인데 멤버 자격 공급자가 인증 서비스에 액세스할 수 없는 경우

예제

다음 예제 코드는 사용자를 로그 아웃 하려면이 메서드를 사용 하는 방법에 설명 합니다.

private void logoutButton_Click(object sender, EventArgs e)
{
    SaveSettings();

    ClientFormsAuthenticationMembershipProvider authProvider =
        (ClientFormsAuthenticationMembershipProvider)
        System.Web.Security.Membership.Provider;

    try
    {
        authProvider.Logout();
    }
    catch (WebException)
    {
        MessageBox.Show("Unable to access the authentication service." +
            Environment.NewLine + "Logging off locally only.",
            "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
        ConnectivityStatus.IsOffline = true;
        authProvider.Logout();
        ConnectivityStatus.IsOffline = false;
    }

    Application.Restart();
}
Private Sub logoutButton_Click(ByVal sender As Object, _
    ByVal e As EventArgs) Handles logoutButton.Click

    SaveSettings()

    Dim authProvider As ClientFormsAuthenticationMembershipProvider = _
        CType(System.Web.Security.Membership.Provider,  _
        ClientFormsAuthenticationMembershipProvider)

    Try

        authProvider.Logout()

    Catch ex As WebException

        MessageBox.Show("Unable to access the authentication service." & _
            Environment.NewLine & "Logging off locally only.", _
            "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
        ConnectivityStatus.IsOffline = True
        authProvider.Logout()
        ConnectivityStatus.IsOffline = False

    End Try

    Application.Restart()

End Sub

설명

이 메서드는 Logout 쿠키 캐시에서 모든 인증 쿠키를 지우고 속성을 현재WindowsIdentity를 포함하는 개체로 WindowsPrincipal 다시 설정합니다 static Thread.CurrentPrincipal.

이 메서드를 호출 하면 현재 사용자는 더 이상 클라이언트 애플리케이션 서비스에 대해 인증 됩니다. 즉, 역할을 통해를 검색할 수 없습니다는 ClientRoleProvider 클래스를 통해 및 설정의 ClientSettingsProvider 클래스입니다. 그러나 사용자 유효한 Windows id를 가질 수 있으므로 여전히 나타날 수 있습니다는 true 다음과 같은 코드의 값: Thread.CurrentPrincipal.Identity.IsAuthenticated합니다. 사용자가 클라이언트 애플리케이션 서비스에 대해 인증되었는지 확인하려면 속성을 통해 CurrentPrincipal static 검색된 속성 값 IPrincipal 이 참조인지 ClientFormsIdentity 확인 Identity 합니다. 그런 다음 확인을 ClientFormsIdentity.IsAuthenticated 속성입니다.

현재 사용자를 다시 인증하려면 메서드 또는 메서드를 ClientFormsAuthenticationMembershipProvider.ValidateUser 호출합니다 static Membership.ValidateUser .

적용 대상

추가 정보