Question

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?

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top