SecurityCallContext.IsCallerInRole(String) 메서드

정의

직접 호출자가 지정된 역할의 멤버인지 확인합니다.

public:
 bool IsCallerInRole(System::String ^ role);
public bool IsCallerInRole (string role);
member this.IsCallerInRole : string -> bool
Public Function IsCallerInRole (role As String) As Boolean

매개 변수

role
String

지정된 역할입니다.

반환

직접 호출자가 지정된 역할의 멤버이면 true이고, 그렇지 않으면 false입니다.

예제

다음 코드 예제를 확인 하려면이 방법의 사용을 보여 줍니다. 호출자는 ServicedComponent 메서드는 지정된 된 역할입니다.

// Set the employee's salary. Only managers can do this.
void SetSalary( double ammount )
{
   if ( SecurityCallContext::CurrentCall->IsCallerInRole( "Manager" ) )
   {
      salary = ammount;
   }
   else
   {
      throw gcnew UnauthorizedAccessException;
   }
}
// Set the employee's salary. Only managers can do this.
public void SetSalary (double ammount)
{
    if (SecurityCallContext.CurrentCall.IsCallerInRole("Manager"))
    {
        salary = ammount;
    }
    else
    {
        throw new UnauthorizedAccessException();
    }
}
' Set the employee's salary. Only managers can do this.
Public Sub SetSalary(ByVal ammount As Double) 
    If SecurityCallContext.CurrentCall.IsCallerInRole("Manager") Then
        salary = ammount
    Else
        Throw New UnauthorizedAccessException()
    End If

End Sub

적용 대상