O'Reilly logo

Professional ASP.NET 3.5 Security, Membership, and Role Management with C# and VB by Stefan Schackow, Bilal Haidar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

14.1. The Roles Class

As with the Membership feature, the Role Manager feature has a static class that can be used as an easy way to access the functionality of the feature. The Roles class has methods and properties that cover the following areas:

  • Public properties that primarily expose the Role Manager data from configuration.

  • Public methods that act as façades on top of the default Role Manager provider.

  • A single utility method that you can use for clearing the Role Manager cookie.

Because most ASP.NET provider-based features follow the same general design, I won't rehash how default providers work or the concept of façade methods mapping to the default provider. These areas work the same way in Role Manager as was described earlier in Chapter 11, which discussed Membership.

Regardless of where Role Manager is used, the feature always requires at least Low trust to work. This means that either an ASP.NET application must run in Low trust or higher to use the feature or, for a non-ASP.NET application, the AspNetHostingPermission must be granted to the calling code with a level of Low or higher.

The public properties on the Roles class for the most part just mirror the configuration settings from configuration. Some of the properties should be familiar to you because they work the exact same way on the static Membership class. Properties that are provider-specific or that involve unique behavior to the Role Manager features are described below.

  • Provider: Returns a RoleProvider ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required