Import users from excel or csv file in AEM

Avatar

Avatar
Give Back
Level 1
girishk10214964
Level 1

Likes

0 likes

Total Posts

6 posts

Correct reply

0 solutions
Top badges earned
Give Back
Ignite 1
Validate 1
View profile

Avatar
Give Back
Level 1
girishk10214964
Level 1

Likes

0 likes

Total Posts

6 posts

Correct reply

0 solutions
Top badges earned
Give Back
Ignite 1
Validate 1
View profile
girishk10214964
Level 1

18-02-2019

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 ??

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,409 likes

Total Posts

12,671 posts

Correct reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,409 likes

Total Posts

12,671 posts

Correct reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

18-02-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.

Answers (5)

Answers (5)

Avatar

Avatar
Level 1
anirudh_sharma1
Level 1

Likes

0 likes

Total Posts

4 posts

Correct reply

0 solutions
View profile

Avatar
Level 1
anirudh_sharma1
Level 1

Likes

0 likes

Total Posts

4 posts

Correct reply

0 solutions
View profile
anirudh_sharma1
Level 1

15-05-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

Avatar

Avatar
Establish
Level 6
antoniom5495929
Level 6

Likes

91 likes

Total Posts

212 posts

Correct reply

39 solutions
Top badges earned
Establish
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile

Avatar
Establish
Level 6
antoniom5495929
Level 6

Likes

91 likes

Total Posts

212 posts

Correct reply

39 solutions
Top badges earned
Establish
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile
antoniom5495929
Level 6

18-02-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

Avatar

Avatar
Boost 250
MVP
Gaurav-Behl
MVP

Likes

250 likes

Total Posts

1,147 posts

Correct reply

283 solutions
Top badges earned
Boost 250
Establish
Give back 300
Give Back 50
Give Back 5
View profile

Avatar
Boost 250
MVP
Gaurav-Behl
MVP

Likes

250 likes

Total Posts

1,147 posts

Correct reply

283 solutions
Top badges earned
Boost 250
Establish
Give back 300
Give Back 50
Give Back 5
View profile
Gaurav-Behl
MVP

18-02-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.

Avatar

Avatar
Give Back
Level 1
girishk10214964
Level 1

Likes

0 likes

Total Posts

6 posts

Correct reply

0 solutions
Top badges earned
Give Back
Ignite 1
Validate 1
View profile

Avatar
Give Back
Level 1
girishk10214964
Level 1

Likes

0 likes

Total Posts

6 posts

Correct reply

0 solutions
Top badges earned
Give Back
Ignite 1
Validate 1
View profile
girishk10214964
Level 1

18-02-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.

Avatar

Avatar
Level 1
rakesh_pawar
Level 1

Likes

0 likes

Total Posts

1 post

Correct reply

0 solutions
View profile

Avatar
Level 1
rakesh_pawar
Level 1

Likes

0 likes

Total Posts

1 post

Correct reply

0 solutions
View profile
rakesh_pawar
Level 1

18-02-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));