Question about Roles

  • Thread starter Thread starter rudolf.ball
  • Start date Start date
R

rudolf.ball

Dear NG,

I plan to have a Datagrid in ASP.NET 2.0, with Users in Rows and Roles
in Columns, eg.

RoleA RoleB RoleC
Bob x x
Sue x x
Frank x x

The amount of Roles and Users is growing, so it shall grow
automatically. I want to click a checkbox, if a User is within a role
or not.

Now my questions:

- How can I get all roles/users automatically?
- How can I dynamically add/remove a users role?
- How can I automatically add roles?

Thank you very much for your help

Rudi
 
Hi Rudi,

Much of the code you need has already been written by Microsoft for its own
Web site administration tool.

If you look in this folder:

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ASP.NETWebAdminFiles

You'll find the source code for managing users and roles.

Good luck!

Ken
Microsoft MVP [ASP.NET]
 
1. Roles.GetAllRoles()

2. Roles.AddUserToRole("username", "rolename")
Roles.RemoveUserFromRoles("username", "rolename")

3. Roles.CreateRole("rolename")


That should do it.
 
Back
Top