We have a custom service which is supposed to send emails to the end users (user data is saved in AEM) whenever a file stored in DAM is modified or a new file is uploaded under a certain DAM location. So, we are using event handler for catching the add/edit event, however, the email should be sent to the end users ONLY if the user has access to that file as per their assigned permissions through groups. So, in our even handler we need to first impersonate the user and then get the session of the impersonated user in order to check if that user has permissions to the file or not.
We are looking for any ideas on how to impersonate a user using code in an AEM service.
Solved! Go to Solution.
Views
Replies
Total Likes
Thanks SivaPrasad for pointing me to the right thread. The solution provided there works.
However, it works only with admin resource resolver but not with any service resource resolver as it gives an error "Impersonation not allowed" even though the service user being used has jcr:all rights on /home.
Do you know if we are forced to use admin resolver if we want to do impersonation?
Hi @gauravs23
I think system user cannot impersonate a non system AEM user because it's a user without password but we can impersonate with other AEM user. Please check below and see if that helps in understanding the limitations.
Yes, that's what I thought too and was looking for another opinion on the same. Thanks for all the help SivaPrasad.