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.
Solved! Go to Solution.
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();
}
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
Views
Replies
Total Likes
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
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
I tried on 6.4 Sp4. Username is getting removed from the "members" tab of the group in useradmin.
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
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();
}
Hi Arun,
Thank you for your help.
Regards,
Indrajith
Views
Replies
Total Likes
Views
Like
Replies