Delete User UUID Reference from Group | Community
Skip to main content
Level 2
August 2, 2019
Solved

Delete User UUID Reference from Group

  • August 2, 2019
  • 8 replies
  • 2591 views

Hi All,

There is a scenario I am facing right now. I have created a Test User and Added him to few groups.

Now I have deleted the user but the user's UUID which is referenced to group is not getting removed from property rep:members in Group.

I am not able to delete that reference even manually from crx as the delete is disabled.

Please help me with this to remove the user reference from group.

My Approach :

Created SQL2 query to fetch the user using rep:principalName and get the node, from that node get UUID and then using that UUID build another SQL2 query get the Group's user belongs to, then I am trying to remove the user reference.

Please suggest me.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by arunpatidar

Hi,

You need to create same user again(with same id), then user will have the same jcr:uuid

Then you can remove grammatically using servlet with admin session

for e.g. I have a user deleteme which I need to delete from all the groups and then remove it

session = request.getResourceResolver().adaptTo(Session.class);

JackrabbitSession jcrSession = (JackrabbitSession) session;

UserManager uM = jcrSession.getUserManager();

User user = (User) uM.getAuthorizable("deleteme");

Iterator<Group> groups = user.memberOf();

while (groups.hasNext()) {

groups.next().removeMember(user);

}

user.remove();

}

8 replies

Adobe Employee
August 2, 2019

Hello,

How did you delete the users? When you delete a user from useradmin, it should be deleting that user from the groups.

But if you delete them directly via CRXDE Lite and the Jackrabbit API then they will not be removed.

Regards,

Vishu

Level 2
August 2, 2019

Hi Vishu,

I have verified by deleting both from useradmin and crx but they are just deleting the use but not the reference of the user that was added to the group in property rep:members.

Regards,

Indrajith

Adobe Employee
August 2, 2019

Right, it is not removing the uuid in crxde but removing the group membership in useradmin. Afair, it was not the case in 5.x versions.

Level 2
August 2, 2019

In my project we are using 6.4

Actually the relationship of user to group is never getting removed, Once a user is added to a group the user's id is never getting removed from the group unless we manually remove.

In crx we can see the uuid resides within the group and in useradmin we can see the userName.

Adobe Employee
August 2, 2019

I tried on 6.4 Sp4. Username is getting removed from the "members" tab of the group in useradmin.

Level 2
August 2, 2019

Yeah it is getting removed. Thank you. 

So please suggest me how to remove user programmatically.

I have tried using the query as I mentioned in my question and tried to remove from crx.

Guide me with new approach.

arunpatidar
Community Advisor
arunpatidarCommunity AdvisorAccepted solution
Community Advisor
August 2, 2019

Hi,

You need to create same user again(with same id), then user will have the same jcr:uuid

Then you can remove grammatically using servlet with admin session

for e.g. I have a user deleteme which I need to delete from all the groups and then remove it

session = request.getResourceResolver().adaptTo(Session.class);

JackrabbitSession jcrSession = (JackrabbitSession) session;

UserManager uM = jcrSession.getUserManager();

User user = (User) uM.getAuthorizable("deleteme");

Iterator<Group> groups = user.memberOf();

while (groups.hasNext()) {

groups.next().removeMember(user);

}

user.remove();

}

Arun Patidar
Level 2
August 2, 2019

Hi Arun,

Thank you for your help.

Regards,

Indrajith