Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

RolePrincipal::GetRoles Method ()

 

Gets a list of roles that the RolePrincipal is a member of.

Namespace:   System.Web.Security
Assembly:  System.Web (in System.Web.dll)

public:
array<String^>^ GetRoles()

Return Value

Type: array<System::String^>^

The list of roles that the RolePrincipal is a member of.

Exception Condition
ProviderException

The Identity property is null.

If CacheRolesInCookie is true and role names have been cached for the user represented by the RolePrincipal, then the GetRoles method will return the list of role names in the cache that the user is a member of. If role names have not been cached, then the GetRoles method returns the list of role names that the user is a member of from the default role Provider. Only role names for the current ApplicationName are returned. To determine whether role names have been cached in the RolePrincipal object, check the IsRoleListCached property.

The following code example displays the roles that the logged-on user is a member of.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0
Return to top
Show:
© 2017 Microsoft