SecurityCallContext.DirectCaller Właściwość

Definicja

SecurityIdentity Pobiera obiekt opisujący obiekt wywołujący bezpośredni tej metody.

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

Wartość właściwości

SecurityIdentity Wartość.

Przykłady

W poniższym przykładzie kodu pokazano użycie tej metody w celu sprawdzenia tożsamości bezpośredniego obiektu wywołującego metodę ServicedComponent .

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

Dotyczy

Produkt Wersje
.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