Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

Add users with specific email to group Edited

Hi guys,

I'm searching for a solution that gives me the opportunity to add users with a certain e-mail adress to an additional group.

At the moment every logged in user is added to an internal confluence group. Some users with a specific e-mail "@abc.de" should be added to an additional group.

The only option i found at the moment would be a groovy script which would do that after the user is created. Or is there an easier way to do that?

I checked all groovy scripts for confluence i could and tried to add them to my needs. Actually it would only need a check for all users with the defined email adress.

import com.atlassian.confluence.user.UserAccessor
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.user.GroupManager
import com.atlassian.user.UserManager

def groupManager = ComponentLocator.getComponent(GroupManager)
def userAccessor = ComponentLocator.getComponent(UserAccessor)

def specialGroup = groupManager.getGroup("special") ?: groupManager.createGroup("special")

def users = userManager.users

def usersToMove = ["anuser", "u100"]

usersToMove.each { username ->

def user = userAccessor.getUserByName(username)

if (user) {
log.info "Add user ${user.name} to the group: 'Special Group'"
groupManager.addMembership(specialGroup, user)
}

 

1 answer

0 votes

Hi @Andre ,

Groovy script you have suggested seems a valid option based on your needs, if not the only one without modifying data from the database directly.

I would invite you to comment on https://jira.atlassian.com/browse/CONFSERVER-56205 - Provide REST API methods to manage users and groups, as this could bring different ways manipulating users and groups without the need of a 3rd party plugin.

Kind regards,
Rafael

i finalized the groovy script and defined a event listener so that the script starts when a new user is created.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Confluence

What do you think is the most *delightful* Confluence feature? Comment for a prize!

- Create your own custom emoji 🔥 - "Shake for Feedback" on mobile 📱 - An endless supply of GIFs via GIPHY 🤩 Is there anything quite as nice as a pleasant surprise? Comment below with what...

402 views 23 8
Join discussion

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