The Membership Manager Control provides you with the ability to easily define roles
and manage role membership in the appropriate tables of your online database. The
operative word here is
online. While the Asp.Net Web Site Administration
Tool (in Visual Studio 2005) also lets you do this, it is making those entries in
the database of your local development database and not the one which is live and
online.
Tools..Role Management
You can get to the Role Management panels by clicking
Tools on the main
toolbar and then clicking on
Role Management on the Tools View.
The Membership Roles view provides a list of currently defined roles as well as
options for defining new roles, deleting a (selected) role and listing the users
for a (selected) role.
As you can imagine, the Membership Manager Control is simply calling the underlying
role management provider to do the work. Asp.Net disables role management
by default and to enable it, you will need to define a section in your application's
web.config to turn it on. If the RoleManager is not enabled, then the Membership
Manager Control will disable the Membership Roles features.
As discussed in our video,
Secure the control with Asp.Net Role Management,
the Asp.Net Web Site Administration Tool helps you to enable role management and
change from "Windows" authentication (default) to "Forms" authentication.
Behind the scenes, that tool enables role management by adding a section to your
web.config file that looks like this:
<roleManager enabled="True"/>
Of course, the roleManager section includes many more options beyond simply "turning
it on" and may contain sub-elements for defining custom role providers. This
MSDN Article provides complete documentation
of the roleManager element and describes how each of the attributes
and child elements may be used.
Creating a Membership Role
You can create new membership roles in your online Asp.Net Membership database using
the Create Role option which is available by clicking Tools->Membership Roles->New
Role. As illustrated below, the Create Role panel prompts you for the name
of your new membership role and includes a Create Role
button to submit the form. The Cancel button lets you return to the Membership
Roles Panel without actually creating the role.
Once you have added the new role, you may then select any user and use the
Edit Membership Roles Panel
to place the user into the new role.
Securing folder access
While the Membership Manager makes it very convenient to create roles and add or
remove members (online), it makes no attempt to create or manage access rules as
is done in the Asp.Net Website Administration Tool. Since access rules are
created or managed with web.config files, this would require run-time write-access
to the folders and those configuration files.
We recommend that you use the Asp.Net Web Site Administration Tool to create and
manage access rules. This tool is available in Visual Studio .Net 2005 by clicking
WebSite->Asp.Net Configuration.
Another reason to use the Asp.Net Configuration tool is in maintaining consistency
between the files on your server and those on your development workstation(s).
Listing members in a Membership Role
If you are interested in knowing which members are in a particular role, you may
use the Show Users option on the Membership Roles Toolbar.
This option is available by clicking Tools->MembershipRoles->Show Users. Note:
You must select a particular role before actually clicking Show Users.

To add or remove a member from a particular membership role, locate the user in
the User List then use the
Edit Membership Roles Panel
to change that user's membership in each of the listed roles.
Role membership is not only about folder access
Many Asp.Net web developers associate role membership with folder access but overlook
the fact that it may also be used in conjunction with other Asp.Net 2.0
features such as the web.SiteMap file.
In this example, a SiteMap element can be made visible (or not
visible) to users of a particular role. Since the Sitemap is used by controls such
as the Asp.Net 2.0 Navigation Controls (Treeview, SiteMapPath and Menu), role membership
can be used to quickly enable or disable menu options or other navigation components.
In addition, the new Asp.Net 2.0 LoginView Control lets you easily
change the content that is displayed on your web pages based on role groups. Again,
the Membership Manager Control provides very handy functionality for moving members
into and out of groups.
Deleting a MembershipRole
If you no longer require a particular Membership Role, you may delete that role
using the Delete Role option on the Membership Roles toolbar. This option
is available by clicking Tools->Membership Roles->Delete Role. Note that you
must have a role selected in the list before clicking this option.

As illustrated, you will receive a warning that you are about to delete the
role. If you select Continue, the role will be deleted and any associations
between members and that role will be removed.
As you can imagine, the Membership Manager Control is simply making a call to the
unerlying role provider's DeleteRole method.
Roles.DeleteRole(RoleName)
If the role contains members, an exception will not be thrown.