SecurityCallContext.DirectCaller Property


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

Namespace:   System.EnterpriseServices
Assembly:  System.EnterpriseServices (in System.EnterpriseServices.dll)

public SecurityIdentity DirectCaller { get; }

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

// 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") )
      throw new UnauthorizedAccessException();

.NET Framework
Available since 1.1
Return to top