Partager via


SecurityCallContext.DirectCaller Propriété

Définition

Obtient un objet SecurityIdentity qui décrit l'appelant direct de cette méthode.

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

Valeur de propriété

Valeur SecurityIdentity.

Exemples

L’exemple de code suivant illustre l’utilisation de cette méthode pour case activée l’identité de l’appelant direct d’une ServicedComponent méthode.

// 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

S’applique à