Hello Guys,
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.
import com.atlassian.jira.bc.user.UserService
import com.atlassian.jira.component.ComponentAccessor
// 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 = "user@jira.com"
// 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)
.sendNotification(sendNotification)
def createValidationResult = userService.validateCreateUser(newCreateRequest)
assert createValidationResult.isValid() : createValidationResult.errorCollection
userService.createUser(createValidationResult)
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)
.inDirectory(directoryId)
.sendNotification(sendNotification)
Please try, thank you.
@Hana Kučerová Thanks a lot , it works.. ..great :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.