Hi friends,
In my AEM, I created some user groups (ex: my-group-1, my-group-2, my-group-3, my-group-4, etc). So, I create some users (ex: my-user-1, my-user-2, my-user-3) and add the user into some groups. Example:
my-user-1 in groups: my-group-1 , my-group-2, my-group-3
my-user-2 in groups: my-group-2 , my-group-3
Now, I want to create a Servlet to get all group of the current user that have a permission. Example, when I login to AEM with my-user-1. I will get a result with (my-group-1 , my-group-2, my-group-3). If I login to AEM with my-user-2, I will get a result with (my-group-2 , my-group-3).
How to do that?
Please, help me with a simple servlet.
Thank you so much,
BienHV
Solved! Go to Solution.
You can use UserManager API ( UserManager (Apache Jackrabbit 2.12.9 API) ) for working with user and groups
Here is example of servlet in which UserManager API has used .
Adobe Experience Manager Help | Using Jackrabbit UserManager APIs to create Adobe Experience Manager...
/Brijesh Yadav
You can use UserManager API ( UserManager (Apache Jackrabbit 2.12.9 API) ) for working with user and groups
Here is example of servlet in which UserManager API has used .
Adobe Experience Manager Help | Using Jackrabbit UserManager APIs to create Adobe Experience Manager...
/Brijesh Yadav
Hi,
You can check below Servlet which get Groups for current user
aem63app-repo/SimpleGetGroup.java at master · arunpatidar02/aem63app-repo · GitHub
Thanks
Arun
Views
Replies
Total Likes
Thanks for your helps,
I will try it.
Thank you so much,
BienHV
Views
Replies
Total Likes
Hi,
I was created a simple server let to get user groups. I can get userId, but I don't know how to get user groups. Could you help me how to do that?
Thank you so much!
Views
Replies
Total Likes
Hi,
did you check the code which I shared?
you can easily get user group from user
Example :
User currentUser = request.getResourceResolver().adaptTo(User.class);
Iterator<Group> currentUserGroups = currentUser.memberOf();
while (currentUserGroups.hasNext()) {
Group grp = (Group) currentUserGroups.next();
groupName = grp.getID();
hmap.put("groupName", groupName);
}
Thanks
Arun
Thank you for your help.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies