Is there any way to deactivate lots of crowd users automatically?

I want to deactivate lots of crowd users automatically. Is there any way to do this without doing manually on GUI?

Crowd CLI isn't available anymore though.

1 answer

0 votes
Bruno Vincent Community Champion Apr 02, 2016

Hi Hisamitsu,

You can use Crowd's REST API: https://developer.atlassian.com/display/CROWDDEV/Crowd+REST+Resources

For instance, the following Groovy script will do the job:

@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7.1' )


import groovyx.net.http.RESTClient


def applicationName = "myapp"
def applicationPassword = "password"


def client = new RESTClient( "http://localhost:8095/crowd/rest/usermanagement/1/".toString() )
client.auth.basic applicationName, applicationPassword


def users = ['john', 'jane', 'bob']
 
users.each{ u->
 
     def body = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><user name=\"$u\"><active>false</active></user>"                         
 
     def response = client.put(path: "user",
                               requestContentType: 'application/xml',
                               query:['username': u],
                               body: body) 
                            
    assert response.status == 204
}

Best regards,

Bruno

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Statuspage

Introducing Statuspage Getting Started guides! First up: What is Statuspage?

Over the next several weeks we'll be sharing some of our Getting Started guides here in the community. Throughout this series of posts, we'd love to hear from customers and non-customers ab...

229 views 4 1
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you