Skip to main content
Level 2
January 10, 2023
해결됨

SQL2 query to list all users in a group

  • January 10, 2023
  • 4 답변들
  • 1816 조회

How to get the list of all users in a group using SQL2 query?

I tried this:

select * from [rep:User] as user inner join [rep:Group] as group on user.[jcr:uuid] = group.[rep:members] where group.[rep:principalName]="myGroup"

 

 

이 주제는 답변이 닫혔습니다.
최고의 답변: Jagadeesh_Prakash

@khalidmomin1  I recommend to try the "Users to CSV Exporter" of ACS AEM Commons instead

 

https://adobe-consulting-services.github.io/acs-aem-commons/features/exporters/users/index.html

 

4 답변

arunpatidar
Community Advisor
Community Advisor
January 10, 2023

Hi,

You can do it this without a query.

 

Session session = getSubserviceSession(); JackrabbitSession jcrSession = (JackrabbitSession) session; UserManager uM = jcrSession.getUserManager(); Group group = (Group) uM.getAuthorizable("my-group"); terator<Authorizable> itr = group.getMembers(); while (itr.hasNext()) { Object obj = itr.next(); if (obj instanceof User) { User user = (User) obj; String uid = user.getID(); } }
Arun Patidar
KhalidMomin1작성자
Level 2
January 10, 2023

I am looking for SQL2 query to generate user and group reports.

Thanks

Jagadeesh_Prakash
Community Advisor
Community Advisor
January 10, 2023

@khalidmomin1  I recommend to try the "Users to CSV Exporter" of ACS AEM Commons instead

 

https://adobe-consulting-services.github.io/acs-aem-commons/features/exporters/users/index.html

 

Himanshu_Singhal
Community Advisor
Community Advisor
January 10, 2023

Hi @khalidmomin1 
Getting group members via SQL2 query won't be possible because it doesn't store the actual path of members. Instead it does store as WeakReference[]. 



As you can see, property holds the members references and not actual path and there's no way using SQL2 query to basically iterate and get each reference absolute path even using inner join IMO. So, the possible way is what described by @arunpatidar 

Best regards,
Himanshu Singhal