Condividi tramite


SecurityCallContext.CurrentCall Proprietà

Definizione

Ottiene un SecurityCallContext oggetto che descrive il contesto della chiamata di sicurezza.

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

Valore della proprietà

Oggetto SecurityCallContext che descrive il contesto della chiamata di sicurezza.

Esempio

Nell'esempio di codice seguente viene illustrato l'uso di questo metodo per ottenere un SecurityCallContext oggetto che descrive il contesto di sicurezza di una chiamata al metodo.

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

Commenti

La proprietà statica CurrentCall è il modo consigliato per accedere al contesto delle chiamate di sicurezza.

Si applica a