Expand my Community achievements bar.

SOLVED

How to identify a User belongs to a nested Group

Avatar

Level 4

Hi,

I have a AEM user say X. I have two groups A and B. User X is member of Group B and Group B is member of Group A. How to identify Whether X is a member of A?

Thanks in advance

Regards,

Vasim

1 Accepted Solution

Avatar

Correct answer by
Level 4

Found the solution.

If I use requiredGroup.isMember(authorizableUser); It is working.

Thank you.

View solution in original post

3 Replies

Avatar

Level 10

You can use the JackRabbit UserManager API to get this type of information -- UserManager (Apache Jackrabbit 2.6.8 API)

Avatar

Level 4

I tried following code. Still it is not working.

Authorizable authorizableUser = userManager.getAuthorizable("X");

Authorizable authorizableGroup = userManager.getAuthorizable("A");

if(authorizableGroup != null && authorizableGroup.isGroup()){

     Group requiredGroup= (Group) authorizableGroup;

     System.out.println(requiredGroup.isDeclaredMember(authorizableUser););

}

It is not even considering X as a member of Group A. In useradmin for user X it showing only Group B. It is not even considering X is a member of Group A.

Avatar

Correct answer by
Level 4

Found the solution.

If I use requiredGroup.isMember(authorizableUser); It is working.

Thank you.