Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

User and group report

Avatar

Level 4

Hi I need a extract of all the users in a particular group in AEM. Please assist.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

If you install ACS Commons, It is providing a report generator - users-to-csv-exporter.html

 

https://localhost:4502/etc/acs-commons/exporters/users-to-csv-exporter.html

once you download the excel, you can filter based on the group name

AEM-User-Report.png

View solution in original post

5 Replies

Avatar

Community Advisor

AEM doesn't have such an inbuilt utility to extract user's information.

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

 

Avatar

Level 1

Brijesh Sir,

 

I recently developed a Groovy scripts that can fetch a User data based on Its' group. Also built the AEM component for the same.

 

Regards

Anand Shekhar 

Avatar

Level 1

mport org.apache.jackrabbit.api.security.user.UserManager;
import org.apache.jackrabbit.api.security.user.UserManager;
import java.util.Iterator;
import org.apache.jackrabbit.api.security.user.User;
import org.apache.jackrabbit.api.security.user.Authorizable;
import org.apache.jackrabbit.api.security.user.Group;

def resourceResolverFactory = getService("org.apache.sling.api.resource.ResourceResolverFactory")
def resourceResolver = resourceResolverFactory.getAdministrativeResourceResolver(null);
UserManager userManager = resourceResolver.adaptTo(UserManager.class);

def authorizable= userManager.getAuthorizable("<<Group-Name>>");
Group group = (org.apache.jackrabbit.api.security.user.Group) authorizable;

Node node = resourceResolver.adaptTo(Node.class);
int count = 1;
Iterator itr = group.getMembers();

if (itr.hasNext()){

 println 'hello'
 
 
 while(itr.hasNext()) {
                String valText="";
                Object obj = itr.next();
                  if(obj instanceof User) {
                        User user = (User) obj;
node = resourceResolver.getResource(user.getPath()).adaptTo(Node.class);
String nodePathStr = user.getPath().toString();

                       if (node.hasProperty("jcr:primaryType")){
String val_primaryType = node.getProperty("jcr:primaryType").getString();
                            if(val_primaryType.equals("rep:User")){

                                        if(node.hasProperty("rep:principalName")){
                                            valText=node.getProperty("rep:principalName").getString();
                                        }
                                        if(node.hasNode("profile")){
                                           if(node.hasProperty("./profile/familyName")){
                                             valText="User ID : "+valText+",... Last Name : "+node.getProperty("./profile/familyName").getString();
                                               }
                                        if(node.hasProperty("./profile/givenName")){
                                              valText=valText+",... First Name : "+node.getProperty("./profile/givenName").getString();
                                              }
                                            if(node.hasProperty("./profile/email")){
                                              valText=valText+",... Email  : "+node.getProperty("./profile/email").getString();
                                              }
                                            if(nodePathStr!=null){
                                                valText =valText+"... Node Path : "+nodePathStr;
                                            }
                                        }
                            }  
                            println count +" " +valText;
                                count++;

                        }
                  }
            }
 
 
 
}

Avatar

Correct answer by
Community Advisor

If you install ACS Commons, It is providing a report generator - users-to-csv-exporter.html

 

https://localhost:4502/etc/acs-commons/exporters/users-to-csv-exporter.html

once you download the excel, you can filter based on the group name

AEM-User-Report.png

Avatar

Community Advisor

Hi @ranadyutis95334  ,

 

Have you tried ACS User Exporter?

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

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-import-aem-groups-a...

Navigate to http://localhost:4502/miscadmin#/etc/acs-commons/exporters and create a new Users to CSV Export page.

Name the page appropriately as the page’s report configuration can be saved and run again later.

santhosh_kumark_1-1603898965016.png

 

  1. Define any custom properties to add to the report. These are relative property paths off the user node ([rep:User])
    • Examples: profile/middleName, preferences/somePref
  2. Group Membership type:
    • Direct: Only include users who are have been explicitly added to a group selected below.
    • Indirect: Only include users who are members through group inheritance of a group selected below.
    • Direct and Indirect: Any group membership.
  3. Groups:
    • Select any number of groups that will be used to filter in users to the report by the group membership type selected above.
  4. Optionally, click Save Configuration at the top to save this configuration to this page. Multiple User to CSV Exporter pages with different configurations can be created.

  5. Click Download User CSV Report to download the CSV Report of the user for easy import into Excel.

 

Regards,

Santosh