Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

Delete User UUID Reference from Group

Avatar

Level 2

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.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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

View solution in original post

8 Replies

Avatar

Employee Advisor

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

Avatar

Level 2

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

Avatar

Employee Advisor

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.

Avatar

Level 2

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.

Avatar

Employee Advisor

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

Avatar

Level 2

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.

Avatar

Correct answer by
Community Advisor

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

Avatar

Level 2

Hi Arun,

Thank you for your help.

Regards,

Indrajith