Create System User using Runmode with ACS Commons in AEM

 

In order to create a system user using runmode (sling:OsgiConfig) with acs-commons, create a config as below.

  1. Create a sling:OsgiConfig under /apps/project-name/config/com.adobe.acs.commons.users.impl.EnsureServiceUser-customServiceUser.xml
  2. Add the below code in config file.
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
    jcr:primaryType="sling:OsgiConfig" 
    principalName="project-system-user" //Add desired system user name here 
    type="add" 
    ensure-immediately="{Boolean}true"
    aces="[type=allow;privileges=jcr:read\,jcr:modifyproperties;path=/content/we-retail]"/>

Once you deploy the code , you can see the system user created in your useradmin with the name you specified in the config file.

Note: You can make modifications as needed.

Hope this helps!!

Happy Coding 🙏

If you like my post and find it helpful, you can buy me a coffee.

Comments

Post a Comment