How to get the list of user's group which is having count of user's less than 5? | Community
Skip to main content
Employee
November 15, 2022
Solved

How to get the list of user's group which is having count of user's less than 5?

  • November 15, 2022
  • 2 replies
  • 1046 views

Hi all,

 

How to get the list of user's group which is having count less than 5 using query debugger? Please share the query statement for this condition. Aem version is aem cloud

 

Thank you.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by arunpatidar

No, you can't check that.

I don't know your use case but you can leverage jcr:createdBy property to filter out further

2 replies

arunpatidar
New Participant
November 15, 2022

Hi,

You cannot achieve this using query alone, once you have results from below query then you need to write java code to check group member count

 

type=rep:Group
path=/home/groups
property=rep:members
property.value=true
property.operation=exists
p.limit=-1

 

 

UserManager userManager = resourceResolver.adaptTo(UserManager.class);
Group group = (Group)  userManager.getAuthorizable(groupFromQuery);
if (group.getMembers() < 5){
// TODO
}

 

Arun Patidar
Employee
November 17, 2022

Hi @arunpatidar ,

Can we check in query debugger whether the group is automatically created? Or is there any property that defines automatically created group?

arunpatidar
arunpatidarAccepted solution
New Participant
November 17, 2022

No, you can't check that.

I don't know your use case but you can leverage jcr:createdBy property to filter out further

Arun Patidar
Saravanan_Dharmaraj
New Participant
November 15, 2022

Hi @keerthana_h_n 

I dont think you can a write a query in debugger to find the number of users in each group. You might need to use the group API [1] in custom code and call the getMembers() method and iterate it to find the size.

 

[1] https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/org/apache/jackrabbit/api/security/user/Group.html