I need a list of all Roles. I have seen that I can get all Roles by Domain or all Roles by a User.
I thought that I could get all Domains, and then do a loop to get all Roles for each Domain.
But it seems you can get a Domain by name only, and I cant hardcode them because there will be new ones from time to time.
So, any idea how I can get all Security Roles? The names as a string would be enough.
Thanks.
You can use :
Roles.GetAllRoles()
from the namespace Sitecore.Security.Accounts
If you want to get all users from a Role you can use:
IEnumerable<User> _roleUsers = Sitecore.Security.Accounts.RolesInRolesManager.GetUsersInRole(Role.FromName("Your role name"), true);