Delete User UUID Reference from Group

indrajithp11346

01-08-2019

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.

Accepted Solutions (1)

Accepted Solutions (1)

Arun_Patidar

MVP

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

}

Answers (7)

Answers (7)

indrajithp11346

02-08-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.

indrajithp11346

02-08-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.

Vish_dhaliwal

Employee

02-08-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.

indrajithp11346

02-08-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

Vish_dhaliwal

Employee

02-08-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