System.Web.Security.Roles.GetRolesForUser Method

Gets a list of the roles that a user is in.

Syntax

public static string[] GetRolesForUser (string username)

Parameters

username
The user to return a list of roles for.

Returns

A string array containing the names of all the roles that the specified user is in.

Remarks

The Roles.GetRolesForUser(string) method calls the RoleProvider.GetRolesForUser(string) method of the default role provider to retrieve from the data source the roles that the user is in. Only the roles for the application that is specified in the Roles.ApplicationName property are retrieved.

If username is equal to the current logged-on user and Roles.CacheRolesInCookie is true, the results of the Roles.GetRolesForUser(string) method may be returned from the role cache rather than the specified Roles.Provider.

Requirements

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