Call RightManagerAPI class in Velocity Macro

Am currently working mapping the user to an group, in UI there is an option of adding one user at a time.

After analyse i found this velocity macro script, to add user into group,
{{velocity }}
#set ($groupdoc = $xwiki.addToAllGroup(“dhivyalakshmig”))
{{/velocity}}

I need to add bulk users at a time. I have referred this RightsManagerUsersApi in that getAllUsers() and loop over above macro.

Am stuck at how to RightManagerUsersApi class this in velocity macro?

Tried cases:
{{velocity }}
$RightManagerUsersApi.getAllUsers()
{{/velocity}}

Nothing works.

Edit a group page in object mode and you’ll see that is has an XWiki.XWikiGroups object for each member. There may be other solutions, but an easy one is to add those objects from Velocity, see http://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/Scripting/APIGuide/#HAddobjectstoapage .