SecurityCallContext.IsCallerInRole Method (String)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Verifies that the direct caller is a member of the specified role.

Namespace:   System.EnterpriseServices
Assembly:  System.EnterpriseServices (in System.EnterpriseServices.dll)

public bool IsCallerInRole(
	string role


Type: System.String

The specified role.

Return Value

Type: System.Boolean

true if the direct caller is a member of the specified role; otherwise, false.

The following code example demonstrates the use of this method to determine if the caller of a ServicedComponent method is in a specified role.

// Set the employee's salary. Only managers can do this.
public void SetSalary (double ammount)
    if (SecurityCallContext.CurrentCall.IsCallerInRole("Manager"))
        salary = ammount;
        throw new UnauthorizedAccessException();

.NET Framework
Available since 1.1
Return to top