Question about Roles

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
 
K

Ken Cox [Microsoft MVP]

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]
 
T

tdavisjr

1. Roles.GetAllRoles()

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

3. Roles.CreateRole("rolename")


That should do it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top