SecurityCallContext.CurrentCall Propriété

Définition

Obtient un objet SecurityCallContext qui décrit le contexte de l'appel de sécurité.

public:
 static property System::EnterpriseServices::SecurityCallContext ^ CurrentCall { System::EnterpriseServices::SecurityCallContext ^ get(); };
public static System.EnterpriseServices.SecurityCallContext CurrentCall { get; }
static member CurrentCall : System.EnterpriseServices.SecurityCallContext
Public Shared ReadOnly Property CurrentCall As SecurityCallContext

Valeur de propriété

Objet SecurityCallContext qui décrit le contexte de l'appel de sécurité.

Exemples

L’exemple de code suivant illustre l’utilisation de cette méthode pour obtenir un SecurityCallContext objet décrivant le contexte de sécurité d’un appel de méthode.

// Set the employee's salary. Only managers can do this.
void SetSalary( double ammount )
{
   if ( SecurityCallContext::CurrentCall->IsCallerInRole( "Manager" ) )
   {
      salary = ammount;
   }
   else
   {
      throw gcnew UnauthorizedAccessException;
   }
}
// Set the employee's salary. Only managers can do this.
public void SetSalary (double ammount)
{
    if (SecurityCallContext.CurrentCall.IsCallerInRole("Manager"))
    {
        salary = ammount;
    }
    else
    {
        throw new UnauthorizedAccessException();
    }
}
' Set the employee's salary. Only managers can do this.
Public Sub SetSalary(ByVal ammount As Double) 
    If SecurityCallContext.CurrentCall.IsCallerInRole("Manager") Then
        salary = ammount
    Else
        Throw New UnauthorizedAccessException()
    End If

End Sub

Remarques

La propriété statique CurrentCall est la méthode recommandée pour accéder au contexte d’appel de sécurité.

S’applique à