System.Web.Security.RolePrincipal.IsInRole Method

Gets a value indicating whether the user represented by the System.Web.Security.RolePrincipal is in the specified role.

Syntax

public bool IsInRole (string role)

Parameters

role
The role to search for.

Returns

true if user represented by the System.Web.Security.RolePrincipal is in the specified role; otherwise, false.

Remarks

RolePrincipal.IsInRole(string) first checks the RolePrincipal.IsRoleListCached property to determine whether a cached list of role names for the current user is available. If the RolePrincipal.IsRoleListCached property is true, the cached list is checked for the specified role. If the RolePrincipal.IsInRole(string) method finds the specified role in the cached list, it returns true.

If RolePrincipal.IsInRole(string) does not find the specified role, it calls the RoleProvider.GetRolesForUser(string) method of the default Roles.Provider instance to determine whether the user name is associated with a role from the data source for the configured Roles.ApplicationName value.

Requirements

Namespace: System.Web.Security
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0