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)
}
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.