cancel
Showing results for 
Search instead for 
Did you mean: 

enable / disable user account with web service

hatspeed
Champ in-the-making
Champ in-the-making
Hello

can anybody help me to find a solution , how to enable / disable user account with web service .

Thanks for any suggestion.

Hatspeed.
2 REPLIES 2

sujaypillai
Confirmed Champ
Confirmed Champ
Hi,

Rather than going with webservice I would suggest to use the existing webscript found in the package -
http://localhost:8080/alfresco/service/index/package/org/alfresco/repository/person


Here below is the CURL command to first create a person ["enabled": true,] check this property which shows account is enabled] and then disabling it
  • [h4]To create an account:[/h4]
  • [spillai@laughlin ~]$ curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"userName":testuser1@gmail.com,"firstName":test,"lastName":user1,"email":testuser1@gmail.com,"password":testuser123}' –user admin:admin123 http://192.168.227.1:8080/alfresco/service/api/people

    {
       "url": "\/alfresco\/service\/api\/person\/testuser1@gmail.com",
       "userName": "testuser1@gmail.com",
       "enabled": true,
       "firstName": "test",
       "lastName": "user1",
       "jobtitle": null,
       "organization": null,
       "location": null,
       "telephone": null,
       "mobile": null,
       "email": "testuser1@gmail.com",
       "companyaddress1": null,
       "companyaddress2": null,
       "companyaddress3": null,
       "companypostcode": null,
       "companytelephone": null,
       "companyfax": null,
       "companyemail": null,
       "skype": null,
       "instantmsg": null,
       "userStatus": null,
       "userStatusTime": null,
       "googleusername": null,
       "quota": -1,
       "sizeCurrent": 0,
       "emailFeedDisabled": false,
       "persondescription": null
    }
  • [h4]To disable an account:[/h4]
  • [spillai@laughlin ~]$ curl -H "Accept: application/json" -H "Content-type: application/json" -X PUT -d '{"disableAccount":true}' –user admin:admin123 http://192.168.227.1:8080/alfresco/service/api/people/testuser1@gmail.com 

    {
       "url": "\/alfresco\/service\/api\/person\/testuser1@gmail.com",
       "userName": "testuser1@gmail.com",
        "enabled": false,
       "firstName": "test",
       "lastName": "user1",
       "jobtitle": null,
       "organization": null,
       "location": null,
       "telephone": null,
       "mobile": null,
       "email": "testuser1@gmail.com",
       "companyaddress1": null,
       "companyaddress2": null,
       "companyaddress3": null,
       "companypostcode": null,
       "companytelephone": null,
       "companyfax": null,
       "companyemail": null,
       "skype": null,
       "instantmsg": null,
       "userStatus": null,
       "userStatusTime": null,
       "googleusername": null,
       "quota": -1,
       "sizeCurrent": 0,
       "emailFeedDisabled": false,
       "persondescription": null
    }

    Hope so that helps you!!!

hatspeed
Champ in-the-making
Champ in-the-making
thank you for your suggestion .
if they are other suggestions with web service , that will be better .

i have found this code in forum  :
private  MutableAuthenticationService authenticationService ;
authenticationService.setAuthenticationEnabled(username, false);
—-
but it give me this exception :
java.lang.NullPointerException


Hatspeed