I am trying to create user in JIRA Internal Directory having ID 1L How can i define directory in Script.
I have tried to define it like :- def directoryId = 1L . But where to put in script so that user get created in Internal directory instead of creating using default directory which in JIRA Delegated Authentication directory.
// the username of the new user - needs to be lowercase and unique - required
final String userName = "user"
// The password for the new user - if empty a random password will be generated
final String password = "password"
// The email address for the new user - required
final String emailAddress = "firstname.lastname@example.org"
// The display name for the new user - required
final String displayName = "New User"
//This display the directory
def directoryId = 1L
// notifications are sent by default, set to false to not send a notification
final boolean sendNotification = false
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def userService = ComponentAccessor.getComponent(UserService)
def newCreateRequest = UserService.CreateUserRequest.withUserDetails(loggedInUser, userName, password, emailAddress, displayName)
def createValidationResult = userService.validateCreateUser(newCreateRequest)
assert createValidationResult.isValid() : createValidationResult.errorCollection
Script Source :- https://library.adaptavist.com/entity/create-a-user-in-jira
Hi @Vikrant Yadav ,
according to this documentation you should be able to do something like:
def newCreateRequest = UserService.CreateUserRequest
.withUserDetails(loggedInUser, userName, password, emailAddress, displayName)
Please try, thank you.
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events