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.

Примеры

В следующем примере кода показано использование этого метода для проверка удостоверения прямого вызывающего 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

Применяется к