SecurityCallContext.DirectCaller プロパティ

定義

このメソッドの直接の呼び出し元を説明する SecurityIdentity オブジェクトを取得します。

public:
 property System::EnterpriseServices::SecurityIdentity ^ DirectCaller { System::EnterpriseServices::SecurityIdentity ^ get(); };
public System.EnterpriseServices.SecurityIdentity DirectCaller { get; }
member this.DirectCaller : System.EnterpriseServices.SecurityIdentity
Public ReadOnly Property DirectCaller As SecurityIdentity

プロパティ値

SecurityIdentity 値。

次のコード例は、このメソッドを使用して、メソッドの直接呼び出し元の ID をチェックする方法をServicedComponent示しています。

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

適用対象