SecurityCallContext 클래스

정의

현재의 메서드 호출을 발생시키는 호출자 체인을 설명합니다.

public ref class SecurityCallContext sealed
public sealed class SecurityCallContext
type SecurityCallContext = class
Public NotInheritable Class SecurityCallContext
상속
SecurityCallContext

예제

다음 코드 예제에서는 합니다 SecurityCallContext 클래스의 메서드 호출의 보안 컨텍스트를 질의 하는 ServicedComponent 클래스입니다.

// Accept a constructor string.

[ConstructionEnabled]
public ref class EmployeeInformation: public ServicedComponent
{
private:

   // The employee's user name and salary.
   String^ accountName;
   double salary;

public:

   // Get the employee's name. All users can call this method.
   String^ GetName()
   {
      return (accountName);
   }

   // 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;
      }
   }

   // Get the employee's salary. Only the employee and managers can do this.
   double GetSalary()
   {
      if ( SecurityCallContext::CurrentCall->DirectCaller->AccountName == accountName || SecurityCallContext::CurrentCall->IsCallerInRole( "Manager" ) )
      {
         return (salary);
      }
      else
      {
         throw gcnew UnauthorizedAccessException;
      }
   }

protected:
   // Use the constructor string.
   // This method is called when the object is instantiated.
   virtual void Construct( String^ constructorString ) override
   {
      accountName = constructorString;
   }
};
// Accept a constructor string.
[ConstructionEnabled]

public class EmployeeInformation : ServicedComponent
{

    // The employee's user name and salary.
    private string accountName;
    private double salary = 0;

    // Get the employee's name. All users can call this method.
    public string GetName ()
    {
      return(accountName);
    }

    // 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();
        }
    }

    // Get the employee's salary. Only the employee and managers can do this.
    public double GetSalary ()
    {
        if ( SecurityCallContext.CurrentCall.DirectCaller.AccountName == accountName ||
             SecurityCallContext.CurrentCall.IsCallerInRole("Manager") )
        {
            return(salary);
        }
        else
        {
          throw new UnauthorizedAccessException();
        }
    }

    // Use the constructor string.
    // This method is called when the object is instantiated.
    protected override void Construct (string constructorString)
    {
        accountName = constructorString;
    }
}
' Accept a constructor string.
<ConstructionEnabled()>  _
Public Class EmployeeInformation
    
    Inherits ServicedComponent
    
    ' The employee's user name and salary.
    Private accountName As String
    Private salary As Double = 0
    
    ' Get the employee's name. All users can call this method.
    Public Function GetName() As String 
        Return accountName
    
    End Function 'GetName
    
    ' 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
    
    ' Get the employee's salary. Only the employee and managers can do this.
    Public Function GetSalary() As Double 
        If SecurityCallContext.CurrentCall.DirectCaller.AccountName = accountName OrElse SecurityCallContext.CurrentCall.IsCallerInRole("Manager") Then
            Return salary
        Else
            Throw New UnauthorizedAccessException()
        End If
    
    End Function 'GetSalary
    
    ' Use the constructor string.
    ' This method is called when the object is instantiated.
    Protected Overrides Sub Construct(ByVal constructorString As String) 
        accountName = constructorString
    
    End Sub

End Class

속성

Callers

호출자를 설명하는 SecurityCallers 개체를 가져옵니다.

CurrentCall

보안 호출 컨텍스트를 설명하는 SecurityCallContext 개체를 가져옵니다.

DirectCaller

이 메서드의 직접 호출자를 설명하는 SecurityIdentity 개체를 가져옵니다.

IsSecurityEnabled

현재 컨텍스트에서 보안 검사가 활성화되는지 여부를 확인합니다.

MinAuthenticationLevel

COM+의 MinAuthenticationLevel 컬렉션에서 ISecurityCallContext 값을 가져옵니다.

NumCallers

COM+의 NumCallers 컬렉션에서 ISecurityCallContext 값을 가져옵니다.

OriginalCaller

원래 호출자를 설명하는 SecurityIdentity를 가져옵니다.

메서드

Equals(Object)

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

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

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

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

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

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

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

IsUserInRole(String, String)

지정된 사용자가 지정된 역할에 있는지 확인합니다.

MemberwiseClone()

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

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

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

(다음에서 상속됨 Object)

적용 대상