Import users from excel or csv file in AEM | Community
Skip to main content
Adobe Employee
February 18, 2019
Solved

Import users from excel or csv file in AEM

  • February 18, 2019
  • 6 replies
  • 8974 views

Hi Team,

We are trying to import the users from the excel or csv file to  specified group in AEM on AEM 6.4, I tried the steps mentioned in Adobe Experience Manager Help | Creating a custom Excel Service for Adobe Experience Manager but no luck , any pointers or alternate way to achieve it on AEM 6.4 ??

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 smacdonald2008

This use case is very possible and be easy to do. You would need to write a custom AEM serviec that can read Excel. You can use the Java EXCEL API to do so. See this older artilce:

Scott's Digital Community: Creating a custom Excel Service for Adobe Experience Manager

Read all of the user data from the EXCEL doc, place in a Java collection object and then iterate through the collection and use the USER MANAGER API to create the users.

6 replies

February 18, 2019

Did you try to create users using the UserManager API? There is an example on Adobe help site. I am just copy-pasting the snippet here, please go throuhg the complete example to understand better.

1. Create a group

Group group=userManager.createGroup(groupName,new SimplePrincipal(groupName),"/home/groups/test");

Value value=adminSession.getValueFactory().createValue("Sample Group", PropertyType.STRING);

group.setProperty("./profile/givenName", value);

value=adminSession.getValueFactory().createValue("Test Group", PropertyType.STRING);

group.setProperty("./profile/aboutMe", value);

value=adminSession.getValueFactory().createValue("abc@gmail.com", PropertyType.STRING);

group.setProperty("./profile/email", value); 

2. Create the user(s)

You can read the csv file, iterate the rows and create the users

User user=userManager.createUser(userName, password,new SimplePrincipal(userName),"/home/users/test");

Value value=adminSession.getValueFactory().createValue("Issac", PropertyType.STRING);

user.setProperty("./profile/familyName", value);

value=adminSession.getValueFactory().createValue("Albin", PropertyType.STRING);

user.setProperty("./profile/givenName", value);

value=adminSession.getValueFactory().createValue("Test User", PropertyType.STRING);

user.setProperty("./profile/aboutMe", value);

value=adminSession.getValueFactory().createValue("albin@gmail.com", PropertyType.STRING);

user.setProperty("./profile/email", value);

3. Add the user to the group

Group group = (Group)(userManager.getAuthorizable(groupName));

group.addMember(userManager.getAuthorizable(userName));

Adobe Employee
February 18, 2019

Thanks for your quick response.

Yes I tried the above link and able to add the user as mentioned, but I am looking for reading the users from the excel or csv file and adding to group.

Gaurav-Behl
Level 10
February 18, 2019

what error do you get in the article you shared? It should work fine, just use maven archetype 13+ and use the same code or if you want to convert the same to R6, that's also possible.

antoniom5495929
Level 7
February 18, 2019

Hi,

you could try to use a cURL command in order to import users into AEM.

You need to run something like the following command:

curl -u admin:admin -FcreateUser= -FauthorizableId=$UserNameReadFromCSV -Frep:password=$PasswordReadFromCSV http://localhost:4502/libs/granite/security/post/authorizables 

Try as described here: cq5 - how import users to AEM/CQ from excel - Stack Overflow

Let us know.

Thanks,

Antonio

smacdonald2008
smacdonald2008Accepted solution
Level 10
February 18, 2019

This use case is very possible and be easy to do. You would need to write a custom AEM serviec that can read Excel. You can use the Java EXCEL API to do so. See this older artilce:

Scott's Digital Community: Creating a custom Excel Service for Adobe Experience Manager

Read all of the user data from the EXCEL doc, place in a Java collection object and then iterate through the collection and use the USER MANAGER API to create the users.

May 15, 2019

May be I am late to the party but I have been working on this requirement and created a utility in the AEM for the same.

This utility allows the users to upload an excel file with the user details and creates users in the AEM to the desired group automatically.

https://aem.redquark.org/2019/05/create-users-in-aem-from-excel-file.html

You can see the code for the same at my GitHub. I hope this helps someone.

https://github.com/ani03sha/BulkUserCreation