Assigning Application Roles

Posted by Community Admin on 04-Aug-2018 08:43

Assigning Application Roles

All Replies

Posted by Community Admin on 05-Jul-2011 00:00

Does anyone know how I can via the API assign a user the roles like "Editors" or "Authors"?

Using the RoleManager.GetManager().GetRole("Editors") is not supported. So one can't call the AddUserToRole() method.

I can't find my way around the documentation and pinpoint the proper keyword to search for.
The one thing I keep hitting is this:

"application roles – these are similar to user roles, but they are assigned to

users automatically based on predefined conditions."

But no clues as to what those conditions are. I can set the roles via the GUI, but I need to do it through code.

 

Any help is most welcome.

.a

 

Posted by Community Admin on 05-Jul-2011 00:00

Hello Anders,

Here is a sample code

RoleManager roleManager = RoleManager.GetManager("AppRoles");
roleManager.Provider.SuppressSecurityChecks = true;
var role = roleManager.GetRole("Administrators");// or any other AppRole
roleManager.AddUserToRole(user, role);
roleManager.SaveChanges();


Best wishes,
Ivan Dimitrov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 05-Jul-2011 00:00

Thank you for a quick response!

.a

This thread is closed