May 27, 2020
Estimated Post Reading Time ~

Apache sling Service User Mapper Service

Problem Statement:
I am using 6.1. I have created a service user and given required permissions in useradmin. When am trying to map the service user in Apache sling Service User Mapper Service Amendment, I have given pwcm.core.schedulers: EventArchiveService=testSystemUser and clicked save but the issue is when I refresh I don't see any value in service mappings its becoming empty and I get the login error in error logs. I don't understand why the value is clearing off from Felix console.

Solution:
Step 1: Create a new system user. to do this
Open http://localhost:4502/crx/explorer/index.jsp

Login as admin > Open 'User Administration > Select 'Create System User' > Enter "user id" > Hit the Green button (you will not se a save button 🙂

I have created "abcwriteservice" user

Step 2: Go to Permissions, and for the user, 'abcwriteservice' give Permissions to access the folder where you'd like to write. (In this example: /etc/userdata )

Step 3: Open OSGI console and go to "Apache Sling Service User Mapper Service" to define the service-user mapping. For example: 'group.commons-service:writeService=abcwriteservice'

Step 4: In code, I added an extra parameter, as:

Map<String, Object> param = new HashMap<String, Object>(); param.put(ResourceResolverFactory.SUBSERVICE, "writeService"); try { resourceResolverWriter = factory.getServiceResourceResolver(param); if (resourceResolverWriter == null) throw new Exception("Could not obtain a CRX User for the Service:'writeService'"); Node usersRootNode = adminSession.getNode("/etc/userdata/users");

Note:
You should be using: "Apache Sling Service User Mapper service" - not "Apache Sling Service User Mapper Service Amendment".


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.