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 vote
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 Join to answer
Community showcase
Emilee Spencer
Published 4 hours ago in Marketplace Apps

Marketplace Spotlight: DeepAffects

Hello Atlassian Community! My name is Emilee, and I’m a Product Marketing Manager for the Marketplace team. Starting with this post, I'm kicking off a monthly series of Spotlights to highlight Ma...

26 views 0 3
Read article

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot