SecurityCallContext.DirectCaller Property

Definition

Gets a SecurityIdentity object that describes the direct caller of this method.

C#
public System.EnterpriseServices.SecurityIdentity DirectCaller { get; }

Property Value

A SecurityIdentity value.

Examples

The following code example demonstrates the use of this method to check the identity of the direct caller of a ServicedComponent method.

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

Applies to

Proizvod Verzije
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1