Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Grovy script to find list of direct access users from particular group

Rao B August 16, 2021

Hi, At the moment we have script that listing all users of a group and well as nested group.

we are using following methods.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.login.LoginManager
import java.text.SimpleDateFormat;
import java.util.Date;

def loginManager = ComponentAccessor.getComponentOfType(LoginManager.class)
def groupManager = ComponentAccessor.getGroupManager()
def users = groupManager.getUsersInGroup("Group1")

StringBuilder builder=new StringBuilder()

 

Can any one please help, how to list direct access users from particular group (we don't want to list sub-group users), only direct access users.

Thanks in advance

3 answers

2 accepted

0 votes
Answer accepted
Martin Bayer [MoroSystems, s.r.o.]
Community Champion
August 16, 2021

Hi @Rao B , can you explain it in more detail? What is the use case scenario?

Rao B August 17, 2021

HI @Martin Bayer [MoroSystems, s.r.o.] , @Nir Haimov ,

Thanks for your response.

At the moment we have many groups and users in our Jira Projects, so we have created many nested groups (e.g- GroupB is the sub-group of GroupA). there are some users are present in parent group(GroupA) as well child group(GroupB),

Our scenario is : To get list of users who are present in parent group (i.e- GroupA).

But we have script it listing all users parent groups as well as child group members.

 

Can you please tell me, How to print list of users from only who are present in parent groups

Thanks in Advance.

Martin Bayer [MoroSystems, s.r.o.]
Community Champion
August 17, 2021

Hi @Rao B I'm not an expert for these functions but

  • groups and subgroups are present in Active directory
  • Jira does not have anything like groups and subgroups
  • it means that function which synchronize users from AD to groups does all the stuff, it probably
    • synchronize users to groups
    • synchronize users of subgroups to groups

So from this point of view you're not able to get such detailed information using Jira API...

0 votes
Answer accepted
Nir Haimov
Community Champion
August 16, 2021

Hi @Rao B 

What do you mean by "direct access"

0 votes
Deleted user March 17, 2022

Hello @Rao B 

you can use these method to get the users who only belongs to a parent group and not the child groups.

getDirectUsersInGroup

Returns all the users that are direct members of the group.

thank you,

Atib

Suggest an answer

Log in or Sign up to answer