How can I get the data of all the users of the system in the publish environment? | Community
Skip to main content
Level 2
August 18, 2023
Solved

How can I get the data of all the users of the system in the publish environment?

  • August 18, 2023
  • 2 replies
  • 795 views

Hello, good afternoon.

 

I need help with a custom component, I have created a table type "Datatable" in which I want all the users of the system to be loaded.

I have it developing and working in the local and author environments, but in the publish environment it doesn't work.

I have tried to develop the servlet in 2 ways to get the data:

 

1.- Through JCR-SQL2, which works in author and local, but in publish it does not return anything.

2.- Going through the nodes manually (/home/users) and showing the users of those nodes, but it doesn't work in the publish environment either.

 

My question is, is there a way to get that data out? Or are they restricted?

 

Thank you.

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 lukasz-m

Hi @alex_terinte,

User data you are trying to get on publish are restricted in the way they are available only for logged in user with appropriate level of permission (at least read permission to entire path /home/users).

I think the root cause of the issue you are facing, is related to the fact, you are using anonymous user session in your servlet which by default does not have access to /home/users. At the same time it could work on author, because most likely you are running your servlet being logged in to the instance (using admin account).

To prove above statement, you can simply login to publish instance using the same user you are using on author and run your servlet - you should get correct result.

The solution for this case, will be to create dedicated service user, that will have proper level of permissions to access /home/users path. Use that user to create resourceResolver/session object you will next use to run query or traverse nodes.

You can find great example how to do this under this article:

2 replies

lukasz-m
Community Advisor
lukasz-mCommunity AdvisorAccepted solution
Community Advisor
August 18, 2023

Hi @alex_terinte,

User data you are trying to get on publish are restricted in the way they are available only for logged in user with appropriate level of permission (at least read permission to entire path /home/users).

I think the root cause of the issue you are facing, is related to the fact, you are using anonymous user session in your servlet which by default does not have access to /home/users. At the same time it could work on author, because most likely you are running your servlet being logged in to the instance (using admin account).

To prove above statement, you can simply login to publish instance using the same user you are using on author and run your servlet - you should get correct result.

The solution for this case, will be to create dedicated service user, that will have proper level of permissions to access /home/users path. Use that user to create resourceResolver/session object you will next use to run query or traverse nodes.

You can find great example how to do this under this article:

DPrakashRaj
Community Advisor
Community Advisor
August 18, 2023

i am wondering why you have this requirement  to pull user information on publisher? Are you doing any user authentication on your site for the user from your aem useradmin?