Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

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

Hisamitsu Koga March 30, 2016

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
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 2, 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
TAGS
AUG Leaders

Atlassian Community Events