Skip to main content
Adobe Employee
November 15, 2022
Solved

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

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.
arunpatidar
arunpatidarAccepted solution
Community Advisor
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

4 replies

Saravanan_Dharmaraj
Community Advisor
Community Advisor
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

Translate
arunpatidar
Community Advisor
Community Advisor
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
}

 

Translate
Arun Patidar
Adobe 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?

Translate
arunpatidar
Community Advisor
arunpatidarCommunity AdvisorAccepted solution
Community Advisor
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

Translate
Arun Patidar