سؤال

I am not able to add a new user to the "confluence-users" group. I am able to add a new user to the database, and when I am trying to add him to the group, it says


"User [Anonymous] does not have the required privileges."

I guess, it needs admin privileges to add a user to group and how can I specify it while adding a user to group. I am using confluence 3.5 api and pls let me know how to achieve this.

My code looks like below..

UserAccessor userAccessor = (UserAccessor)ContainerManager.getInstance().getContainerContext().getComponent("userAccessor"); Group group = userAccessor.getGroup(UserAccessor.GROUP_CONFLUENCE_USERS); DefaultUser defaultUser = new DefaultUser(username,fullname,email); User newuser = userAccessor.createUser(defaultUser,Credential.unencrypted(password)); userAccessor.addMembership(group,newuser);

هل كانت مفيدة؟

المحلول

Try this:

UserManager userManager = (UserManager) ContainerManager.getComponent("userManager");
userManager.createUser(newUser, Credential.NONE);
groupManager.addMembership(group, user);

You'll need to inject the GroupManager in your class.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top