is there a way to create a confluence user in a specified directory using groovy script?

Malesys Elie December 20, 2022


I'm able to create a confluence user in groovy with the following script :


import com.atlassian.confluence.user.UserAccessor
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.user.UserManager

UserManager userManager = ComponentLocator.getComponent(UserManager);
UserAccessor userAccessor = ComponentLocator.getComponent(UserAccessor);
but I don't find any way to specify the user directory that should be used.
can someone help?

2 answers

1 vote
Tansu Akdeniz
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 20, 2022
Ken McClean
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 5, 2023

Original user never replied, but this seems to be the answer

0 votes
Jacky Zhou
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 24, 2024

Here's how I create a user in Confluence Data Center 8.5.3, and add the user into a group.

Sorry, this didn't answer the question. But I record it here, since when I google how to create a user in Confluence using groovy, this post always comes on the first page. So I'd like to record the codes here, hope it could help someone.

import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.confluence.user.UserAccessor
import com.atlassian.confluence.user.ConfluenceUserImpl
import com.atlassian.user.GroupManager

def userAccessor = ComponentLocator.getComponent(UserAccessor)
def groupManager = ComponentLocator.getComponent(GroupManager)

def user = new ConfluenceUserImpl("foo", "foo", "foo@email.local")
userAccessor.createUser(user, Credential.unencrypted('your password here'))

def group = groupManager.getGroup("some-group")
userAccessor.addMembership(group, user)


Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events