Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

ClaimsPrincipal.IsInRole(String) Method

Definition

Namespace:
System.Security.Claims
Assemblies:
mscorlib.dll, System.Security.Claims.dll
Assemblies:
netstandard.dll, System.Security.Claims.dll
Assembly:
System.Security.Claims.dll
Assembly:
mscorlib.dll
Assembly:
netstandard.dll
Source:
ClaimsPrincipal.cs
Source:
ClaimsPrincipal.cs
Source:
ClaimsPrincipal.cs
Source:
ClaimsPrincipal.cs
Source:
ClaimsPrincipal.cs

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Returns a value that indicates whether the entity (user) represented by this claims principal is in the specified role.

public:
 virtual bool IsInRole(System::String ^ role);
public virtual bool IsInRole(string role);
abstract member IsInRole : string -> bool
override this.IsInRole : string -> bool
Public Overridable Function IsInRole (role As String) As Boolean

Parameters

role
String

The role for which to check.

Returns

true if claims principal is in the specified role; otherwise, false.

Implements

Remarks

The IsInRole method checks whether an identity that this claims principal possesses contains a claim of type ClaimsIdentity.RoleClaimType where the value of the claim is equal to the value specified by the role parameter.

Note

Each ClaimsIdentity has its own definition of the claim type that represents a role. This claim type can be accessed and set through the ClaimsIdentity.RoleClaimType property.

Applies to


Feedback

Was this page helpful?