Delete User UUID Reference from Group | Community
Skip to main content
Level 2
Aug 2, 2019 6:34 AM UTC
Solved

Delete User UUID Reference from Group

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.
arunpatidar
arunpatidarAccepted solution
New Participant
Aug 2, 2019 2:40 PM UTC

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

8 replies

Level 2
Aug 2, 2019 4:37 PM UTC

Hi Arun,

Thank you for your help.

Regards,

Indrajith

Translate
arunpatidar
arunpatidarAccepted solution
New Participant
Aug 2, 2019 2:40 PM UTC

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();

}

Translate
Arun Patidar
Level 2
Aug 2, 2019 2:17 PM UTC

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.

Translate
Employee
Aug 2, 2019 1:51 PM UTC

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

Translate
Level 2
Aug 2, 2019 1:38 PM UTC

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.

Translate
Employee
Aug 2, 2019 1:11 PM UTC

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.

Translate
Level 2
Aug 2, 2019 12:47 PM UTC

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

Translate
Employee
Aug 2, 2019 12:37 PM UTC

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

Translate