If you need to get a base roles for role, you can use the GetRolesForRole(Role role, bool includeIndirectMembership)
method of RolesInRolesManager
.
For example, if you need to get a base roles for each role of user, you can use something like below:
foreach (var role in Sitecore.Context.User.Roles)
{
var basedRoldes = RolesInRolesManager.GetRolesForRole(role, true);
}
The RolesInRolesManager
is defined at the Sitecore.Security.Accounts
namespace.
If includeIndirectMembership flag is false, the method will return just a base roles for role. If flag is true, the method will also return a base roles of each base role.