Example scripts
To homepage
Confluence

Enable Disabled Users
App in script

ScriptRunner For Confluence
by Adaptavist
Compatibility

Confluence (7.15 - 8.6)

ScriptRunner For Confluence (7.10.0)
Language |
groovy
import com.atlassian.confluence.user.DisabledUserManager
import com.atlassian.crowd.embedded.api.CrowdService
import com.atlassian.sal.api.component.ComponentLocator
import com.onresolve.scriptrunner.parameters.annotation.ShortTextInput
@ShortTextInput(label = "Users", description = "Type usernames of deactivated users you would like to reactivate, seperated by spaces")
String names
assert names
def disabledUsers = names.split()
def disabledUserManager = ComponentLocator.getComponent(DisabledUserManager)
def crowdService = ComponentLocator.getComponent(CrowdService)
disabledUsers.each { userName ->
def user = crowdService.getUser(userName)
if (user) {
if (disabledUserManager.isDisabled(user)) {
disabledUserManager.enableUser(user)
log.info("User $user.name has been enabled")
} else {
log.info("User $user.name is not disabled")
}
} else {
log.debug("User $userName was not found.")
}
}
Having an issue with this script?
Report it here