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
Published Feb 27, 2018 in Crowd

The Crowd team is looking for feedback on Server & Data Center customers' identity strategies!

Do you own more than one Server or Data Center product? Do you have challenges provisioning users across your Atlassian products? Are you spending a lot of time integrating each Atlassian product wit...

1,514 views 6 14
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