Gajendra
Gajendra

Reputation: 1291

How to get all rolegroups in dotnetnuke

RoleController.GetRoleGroups(portalid); is giving only user created group not Global Roles Group that is created by default.

Upvotes: 5

Views: 1479

Answers (2)

bdukes
bdukes

Reputation: 155905

The global role group is really the absence of a role group. So, the "global" group is roles with a group ID of -1.

Upvotes: 3

Pranav
Pranav

Reputation: 8871

You can use RoleController.GetRoleGroups() for this :-

 var arrGroups = RoleController.GetRoleGroups(portalSettings.PortalId);
   foreach (RoleGroupInfo roleGroup in arrGroups)
   {
    //Your Logic goes here :-
   }

You can use RoleController.GetRoles() for this :-

There are two overload of this method :-

 IList<RoleInfo> GetRoles(int portalId, Func<RoleInfo, bool> predicate);

 IList<RoleInfo> GetRoles(int portalId);

You can see the Source code here :-

This is how you can use the method :-

foreach (var role in TestableRoleController.Instance.GetRoles(portalId))
{
    // you can Put your Logic here :-
}

Upvotes: 4

Related Questions