Create user from Script Runner into MS AD with OU info

I'm trying to create users in a transition from Script Runner (Groovy-script), and it works fine. But it's kinda limited in what type of information is added to the user. It seem as it's not possible to add any org.unit (OU) to the created user, thus failing to follow the "standard" in our MS Active Directory.

We have this structure:

CN=FirstName LastName,OU=<section>,OU=<department>,OU=<companyName>,DC=<domain>,DC=no

When I create a user from SR, I get this structure from where the directory three starts:

CN=kxz,OU=<CompanyNameTest>,DC=<domain>,DC=no

From my Groovy script I also want to add the correct OU (department) and all the sections inside a department.

Is this possible with Script Runner and JIRA? Either after the user is created with som "change user in AD code", or when the user is created.

This is my create user code:

loggedInUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def userService = ComponentAccessor.getComponent(UserService)
//DirectoryId=10100 // TEST AD
UserService.CreateUserRequest createUserRequest = UserService.CreateUserRequest.withUserDetails(loggedInUser, usernameValue, null, userNameValue + "@domain.no", firstnameValue + " " + lastNameValue).inDirectory(10100L)

UserService.CreateUserValidationResult result = userService.validateCreateUser(createUserRequest)

if(result.isValid()) {
userService.createUser(result)
}

 

 

 

0 answers

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,774 views 11 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot