SecurityCallContext.CurrentCall Właściwość
Definicja
Ważne
Niektóre informacje odnoszą się do produktu w wersji wstępnej, który może zostać znacząco zmodyfikowany przed wydaniem. Firma Microsoft nie udziela żadnych gwarancji, jawnych lub domniemanych, w odniesieniu do informacji podanych w tym miejscu.
SecurityCallContext Pobiera obiekt opisujący kontekst wywołania zabezpieczeń.
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
Wartość właściwości
SecurityCallContext Obiekt opisujący kontekst wywołania zabezpieczeń.
Przykłady
Poniższy przykład kodu przedstawia użycie tej metody w celu uzyskania SecurityCallContext obiektu opisującego kontekst zabezpieczeń wywołania metody.
// 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
Uwagi
Właściwość statyczna CurrentCall jest zalecanym sposobem uzyskiwania dostępu do kontekstu wywołania zabezpieczeń.