logo

Getting user's groups

Add the namespace:

using EleWise.ELMA.Security.Managers
 

Below is a script which gets all the groups a specific user (context.Executor) is included in.

var groups = UserGroupManager.Instance.GetGroupsByUser(context.Executor.Id).Select(id => UserGroupManager.Instance.Load(id)); //get all the groups of the user
            foreach(var group in groups.ToList())
            {
                Console.WriteLine(group.Name); //display the name in the console
            }