ClientRolePrincipal 클래스

정의

클라이언트 애플리케이션 서비스에 대한 역할 정보를 비롯한 보안 정보를 나타냅니다.

public ref class ClientRolePrincipal : System::Security::Principal::IPrincipal
public class ClientRolePrincipal : System.Security.Principal.IPrincipal
type ClientRolePrincipal = class
    interface IPrincipal
Public Class ClientRolePrincipal
Implements IPrincipal
상속
ClientRolePrincipal
구현

예제

다음 예제 코드에서는 사용자가 "manager" 역할인 경우에 단추를 표시 하려면이 클래스를 사용 하는 방법에 설명 합니다. 이 예제는 Button 라는 managerOnlyButton 초기값을 사용 하 여 Visible 속성 값 false합니다.

private void DisplayButtonForManagerRole()
{
    try
    {
        ClientRolePrincipal rolePrincipal =
            System.Threading.Thread.CurrentPrincipal 
            as ClientRolePrincipal;

        if (rolePrincipal != null && rolePrincipal.IsInRole("manager"))
        {
            managerOnlyButton.Visible = true;
        }
    }
    catch (System.Net.WebException)
    {
        MessageBox.Show("Unable to access the roles service.",
            "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
    }
}
Private Sub DisplayButtonForManagerRole()

    Try

        Dim rolePrincipal As ClientRolePrincipal = TryCast( _
            System.Threading.Thread.CurrentPrincipal, ClientRolePrincipal)

        If rolePrincipal IsNot Nothing And _
            rolePrincipal.IsInRole("manager") Then

            managerOnlyButton.Visible = True

        End If

    Catch ex As System.Net.WebException

        MessageBox.Show("Unable to access the role service.", _
            "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)

    End Try

End Sub

설명

클라이언트 애플리케이션 서비스에서 사용자의 유효성을 ClientFormsAuthenticationMembershipProvider 검사할 때 속성이 이 클래스의 인스턴스로 설정 static Thread.CurrentPrincipal 됩니다ClientWindowsAuthenticationMembershipProvider. ClientFormsAuthenticationMembershipProvider 초기화를 Identity 속성의 새 인스턴스를 ClientFormsIdentity 클래스. 메서드 ClientWindowsAuthenticationMembershipProvider 에서 반환 static WindowsIdentity.GetCurrent()Identity 개체로 WindowsIdentity 속성을 초기화합니다.

수는 없습니다 일반적으로이 클래스에 직접 액세스 합니다. 일반적으로 속성에서 반환된 IsInRole 메서드를 IPrincipal 호출합니다 static CurrentPrincipal . 캐스팅할 수 있습니다는 CurrentPrincipal 속성 값을 ClientRolePrincipal 호출에 대 한 참조를 IsInRole 메서드 예제 단원에 설명 된 대로 명시적으로 합니다.

생성자

ClientRolePrincipal(IIdentity)

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

속성

Identity

ClientRolePrincipal과 관련된 보안 ID를 가져옵니다.

메서드

Equals(Object)

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

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

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

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

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

(다음에서 상속됨 Object)
IsInRole(String)

ClientRolePrincipal로 나타낸 사용자가 지정된 역할에 있는지 여부를 나타내는 값을 가져옵니다.

MemberwiseClone()

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

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

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

(다음에서 상속됨 Object)

적용 대상

추가 정보