Obtaining all users of a group with a script

This article demonstrates a script that can collect all the users of a certain group and write them to a variable.
There are three types of elements that a group can include:
1) Users
2) Organizational Structure elements assigned to the users 
3) Other groups that may contain users, organizational structure elements, and groups.
In our case by "users of a group" we understand the first type, Users.

Script without PublicAPI.

The script uses the following context variable:

context.Poljzovateli - Users, User type variable, link type - List 

You need the following namespaces:

using EleWise.ELMA.Security.Models;
using EleWise.ELMA.Security.Managers;

Script text:

var filter=new UserGroupFilter();
filter.ShowOnlyGroups=true; //search by groups
filter.SearchString="All users"; //specify group name for search
var grp=UserGroupManager.Instance.Find(filter,null);
foreach(var item in grp.First().Users.ToList()) 
            var user=(User)item;
Creating a similar script with PublicAPI
Updated documentation on PublicAPI is available here.

Context variable:

context.Poljzovateli - Users, User type variable, link type - List 


using EleWise.ELMA.API;
var grp = PublicAPI.Portal.Security.UserGroup.Filter().SearchString("All users").Find().First().Users.ToList();
foreach (var item in grp)
    var user = item;