다음을 통해 공유


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 메서드는 쿠키 캐시에서 모든 인증 쿠키를 지우고 다시 설정 합니다 staticThread.CurrentPrincipal 속성을를 WindowsPrincipal 현재 포함 된 개체 WindowsIdentity합니다.

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

현재 사용자 재인증을 호출 합니다 ClientFormsAuthenticationMembershipProvider.ValidateUser 메서드 또는 staticMembership.ValidateUser 메서드.

적용 대상

추가 정보