System.Web.Security.Roles.IsUserInRole Method

Gets a value indicating whether the currently logged-on user is in the specified role.

Syntax

public static bool IsUserInRole (string rolename)

Parameters

rolename
Documentation for this section has not yet been entered.

Returns

true if the currently logged-on user is in the specified role; otherwise, false.

Remarks

The Roles.IsUserInRole(string) method calls the RoleProvider.IsUserInRole(string, string) method of the default role provider to determine whether the currently logged-on user is associated with a role from the data source for the application that is specified in the Roles.ApplicationName property. The currently logged-on user is identified by the System.Web.HttpContext.User property of the current System.Web.HttpContext, or by System.Threading.Thread.CurrentPrincipal for non-HTTP hosting environments. If no user is logged on, an exception will be thrown. Only the roles for the application that is specified in the Roles.ApplicationName property are retrieved.

If Roles.CacheRolesInCookie is true, then roleName may be checked against the roles cache rather than the specified role provider.

Requirements

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