AEM6.5 how to get user details and the groups the user is associated to in author environment

Avatar

Avatar

srinivas_chann1

Avatar

srinivas_chann1

srinivas_chann1

04-01-2021

Hi,

 

Once any user  logs in to the author environment how could I get the details of the groups the user is member of.

 

I am using js so wanted to check if there is any json available through which I could get this details. Instead of me building a new code for this.

 

I noticed that for authorizables.json  we need to provide the username.

http://localhost:4502/bin/security/authorizables.json?filter=username&_charset_=utf-8

 

Now if is the case i would need a way to find the user name in the js and then again send the request. 

 

Please let me know as I could resolve this in a better way .

 

 

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

shelly-goel

MVP

Avatar

shelly-goel

MVP

shelly-goel
MVP

05-01-2021

@srinivas_chann1 

In js, you can get the user as Granite.author.ContentFrame.getUserID()

Please refer to the function getUserGroups() here:

http://experience-aem.blogspot.com/2019/09/aem-6510-authoring-restrict-msm-rollout-to-specific-user-...

Answers (1)

Answers (1)

Avatar

Avatar

Suraj_Kamdi

MVP

Avatar

Suraj_Kamdi

MVP

Suraj_Kamdi
MVP

04-01-2021

@srinivas_chann1 

I would suggest using the service user to get the details of AEM user/groups. Make use of Authorizable API

https://helpx.adobe.com/experience-manager/6-5/sites/developing/using/reference-materials/javadoc/or... 

 

see the following code snippet

 

 

public static Group getGroup(String userId, UserManager userManager) {
    try {
      return (Group) userManager.getAuthorizable(userId);
    } catch (RepositoryException e) {
      logger.error("Error {}", e);
    }
    return null;
  }