I have created Closed User Groupe My_CUG
in crx
and added some users user1
and user2
. I would like to get the user registered in My_CUG
and their email. How can I Access My_CUG
programmatically?
Asked
Active
Viewed 1,126 times
1

Kristopher Peter
- 145
- 4
- 13
1 Answers
2
You can do that in the following way -
If you group name is "My_CUG" then you can resolve the corresponding group object by using the correct admin privileges -
Session adminSession = resourceResolver.adaptTo(Session.class);
UserManager um = AccessControlUtil.getUserManager(adminSession);
Group naGrp = (Group) um.getAuthorizable("My_CUG");
Now you can add any user (user1) to this group by -
naGrp.addMember(user1_Object);
Hope this solves your problem.

Hari Reddy
- 3,808
- 4
- 33
- 42