Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to create Jira Group using distribution list(DL) without using existing LDAP configuration

Hello Everyone!!

 

How can i achieve creating a Jira group with the list of users present in a distribution list(DL), note that already i have configured the LDAP group which i don't want to disturb and create a new group and manage at the project level. 

can we use script runner to create groups? 

Any suggestions would be appreciated!!

2 answers

Hello @Vijay Sv 

Can you tell us what you are trying to accomplish with this? How do you want to use that Group within JIRA?

To brief, i want to manage a group of contractors who are part of this DL at the project role level and I don't want to disturb the existing LDAP directory where we have permanent Employees and partially contractors. 

I tried adding multiple LDAP directories A & B by adding them to individual groups 1 & 2 as they log in for the first time, users who are part of A will be added to 1 and B will be added 2, perhaps if a contractor is present in both the directories then as they log in the user will be added to the first configured directory then the actual one. 

So i think it cannot be achieved using multiple LDAP directories and i am looking for a way to use scriptrunner/groovy to fetch users from contractors DL to an internal group or any plugin to create an internal group based on the DL.

0 votes

With scriptrunner ... if you can do something in the UI, its generally safe to assume you can do it with a script ... but that means learning the deep innards of the Jira Java API as much as any plugin developer would have to learn.


You will find many examples in this forum. For example:

https://community.atlassian.com/t5/forums/searchpage/tab/message?advanced=false&allow_punctuation=false&q=scriptrunner+add+user+to+group

https://community.atlassian.com/t5/forums/searchpage/tab/message?advanced=false&allow_punctuation=false&q=scriptrunner+create+group

Thanks, @Peter-Dave Sheehan for the lead...

Yeah, i figured to load a bunch of users using a script but wondering how to append the list of users who are in the DL ? maybe loading it to CSV using python or simple Powershell to get the users list from the DL and appending to the script.

 

Here is my script to add multiple users to a group... 

 

import com.atlassian.jira.component.ComponentAccessor


def userUtil = ComponentAccessor.userUtil
def userManager = ComponentAccessor.userManager
final String groupName = "GROUPA" // the group you want to add users
def group = ComponentAccessor.groupManager.getGroup(groupName) // user names of the users to add
final List<String> userToAdd = ["USR1", "USR2", "USR3"]


userToAdd.each {
def usertoadd = userManager.getUserByName(it)
if (!usertoadd) {
log.warn("User: $userToAdd doesn't exist")
return

}

if (ComponentAccessor.getGroupManager().getGroupsForUser(usertoadd).contains(group)) {
log.warn("User: $usertoadd.username already in the group: $groupName")
return

}

if(!group) {
log.warn("Group: $groupName doesn't exist")

} else {

userUtil.addUserToGroup(group, usertoadd)
log.warn("User: $usertoadd.username added to the $groupName")

}

}

If you need to get the list of users from an external source... how you do that depends on the source.

If the data is in LDAP you can connect to LDAP directly from a groovy script

Something like

@Grab(group='org.apache.directory.api', module='api-all', version='2.0.1')
import org.apache.directory.ldap.client.api.*
def ldap = new LdapNetworkConnection(hostName, port)
ldap.bind('userDn', 'userPassword')

Then refer to https://nightlies.apache.org/directory/api/2.0.1/apidocs/ for how to user the various methods.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.5.5
TAGS
Community showcase
Published in Bitbucket Pipelines

Bitbucket Pipelines Runners is now in open beta

We are excited to announce the open beta program for self-hosted runners. Bitbucket Pipelines Runners is available to everyone. Please try it and let us know your feedback. If you have any issue...

378 views 9 8
Read article

Community Events

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

Events near you