Create System User in AEM

AEM 6.1 comes with lot of features, one of those is allowing developer or content authors to create system user from CRX explorer.

The focus of this tutorial is to have a clear understanding about:

System User In AEM:-


Till AEM 6 we have the liberty to use any user as service user, for invoking and executing any service. But from AEM 6.1 there was a slight change on how to define the ServiceUserMapping and how the service user or system user has to be created.

If we try to assign any arbitrary user as service user in AEM 6.1 we would face below error :

org.apache.sling.api.resource.LoginException: Cannot derive user name for bundle ch.inside.cqblog-bundle [452] and sub service readService

Note:- From AEM 6.1 service users can only be mapped to system users (jcr:primaryType = rep:SystemUser).

Why System User are Introduced:-


Use of admin session and admin resource resolver through ResourceresolverFactory is now deprecated, that’s why from AEM 6.1 Adobe forces developers to create system users and map them to Service User Mapper in Felix Console.

  • Prevent excessive use of administrative JCR Sessions and ResourceResolvers.
  • Allow services access to ResourceResolvers and JCR Sessions without requiring to hard-code or configure passwords.
  • Allow services to use service users and/or system user which are specially configured for service level access.

Create System User in AEM:-


A system user can either be created by definition in your application content package or manual creation in the CRX Explorer through “User Administration”. As this is a system user, no need to set a password.

  • Go to CRX Explorer.
    user_administration_crx_explorer_aem6
  • Click on User Administration.
  • Click on Create system User from Top Bar.
    •  UserId- testSystemUser (User Id of system user you want to assign)
    • Intermediate Path – /home/users/system

      Note:- Path where you want to store system user. If no path is provided it will store user at some arbitrary node. This field is optional, but it is always advisable to provide path so that it will be easy to track user.

create_system-user_aem_crx_explorer_manually

  • Click on Green check box.
  • Your system user is successfully created.
    system_user_created_aem_6.1
  • You can also view system user details from CRX DE at this path /home/user/system.
    system_user_crx_de_location_aem

Define Service User Mapper in AEM :-


For defining a service user mapper, a new configuration can be created using Apache sling Service User Mapper Service Amendment.

  • Go to Felix Console configurations.
  • Search for “service user mapper” configuration.
  • Click on Plus sign against Apache sling Service User Mapper Service Amendment to create new factory configuration.
  • Enter Service Mapping Details
    • Enter entry in form of BundleId:subserviceName=userName.

Apache_sling_Service_User_Mapper_Service_Amendment_aem

  • For example in below screenshot:
    • bundleId = com.adobe.cq.cq-dms-tagmanager
    • subServiceName =tagmanagement
    • systemUser Name =tagmanagerservice

apache_sling_service_mapper_example_aem

 

Spread the love
  •  
  •  
  •  
  •  
  •  
  •  

Leave a Reply

Your email address will not be published. Required fields are marked *