Constable Authorization Engine 2.0 BETA

AuthorizationPolicy.IsRoleMember Method 

[This is preliminary documentation and subject to change.]

Determines if the given principal is member of the given role.

[Visual Basic]
Overridable Protected Function IsRoleMember( _
   ByVal principal As IPrincipal, _
   ByVal role As Role _
) As Boolean
[C#]
protected virtual bool IsRoleMember(
   IPrincipal principal,
   Role role
);

Parameters

principal
The IPrincipal whose role membership is checked.
role
The Role to check membership within.

Return Value

true if the principal is member of the role; false otherwise.

Remarks

The implementation simply invokes the role.IsMember(principal) method.

Example

The following is an example of an overriden IsRoleMember method. The example simply returns false from the method thus making the authorization policy refuse to execute action regardless of the CurrentPrincipal role membership:

[Visual Basic]
Private Class NoOpAuthorizationPolicy
  Inherits AuthorizationPolicy
  Protected Overrides Function IsRoleMember(ByVal principal As IPrincipal, ByVal role As Role) As Boolean
    Return False
  End Function
End Class

[C#]
private class NoOpAuthorizationPolicy : AuthorizationPolicy
{
  protected override bool IsRoleMember(IPrincipal principal, Role role)
  {
    return false;
  }
}

See Also

AuthorizationPolicy Class | LaMarvin.Constable Namespace