[NUXEO IDE] impossible to change user's group without restarting the server
Hello,
I would like to add a user to a nuxeo group with an automation operation write in IDE.
I try to do that with :
String groupName="group";
String user="userlogin";
NuxeoGroup group = usermanager.getGroup(groupName);
NuxeoPrincipal up=usermanager.getPrincipal(user);
List<String> userGroups = up.getGroups();
userGroups.add(group.getName());
up.setGroups(userGroups);
//this part don't works
usermanager.updatePrincipal(up);
//same problem don't update
DocumentModel userModel = userManager.getUserModel(user);
userModel.setProperty("user", "groups", userGroups);
userManager.updateUser(userModel);
//this part works
group.getMemberUsers().add(user);
usermanager.updateGroup(group);
The group's user are Ok, but the user's group information is not set while I don't restart the server.
Why ? Why group is instantally set and user not?
What can I do to make this work ?
thanks
ps: try also code nuxeo code example and it failed.
ps2 : my user is a ldap user
0 votes
0 answers
1877 views
My 2 cents: org.nuxeo.ecm.restapi.server.jaxrs.usermanager.UserToGroupObject is showing an example to add a user to a group:
UserManager um = Framework.getLocalService(UserManager.class); principal.setGroups(groups); um.updateUser(principal.getModel());
Hope it helps