SecurityCallContext.IsCallerInRole(String) Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Verifica que o chamador direto pertence ao papel especificado.
public:
bool IsCallerInRole(System::String ^ role);
public bool IsCallerInRole(string role);
member this.IsCallerInRole : string -> bool
Public Function IsCallerInRole (role As String) As Boolean
Parâmetros
- role
- String
O papel especificado.
Devoluções
true se o chamador direto for membro do papel especificado; caso contrário, false.
Exemplos
O exemplo de código seguinte demonstra a utilização deste método para determinar se o chamador de um ServicedComponent método está num papel especificado.
// 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