I can create, update, query, etc a Person. But no DELETE? Why? I've been Googling and can't find a mention of this anywhere. Using community v6.2.
Solved! Go to Solution.
I think there is no V1 api to delete person or at least it is not document in dcumentation if there is even any.
However, you can use Person Update V1 api to disable the user as a workaround. If users are synced from AD, it is recommended to disable the user instead of deleting it.
If you still need to delete the user, use the Repository api: https://docs.alfresco.com/5.0/references/RESTful-PersonPersonDelete.html
Value | Description |
---|---|
json | The default response format |
admin | The authentication access |
required | The transaction level |
argument | The format style |
Example:
HTTP DELETE Request: http://localhost:8080/alfresco/service/api/people/testUser
Note that, only users with admin role can create/update/delete users and groups.
I think there is no V1 api to delete person or at least it is not document in dcumentation if there is even any.
However, you can use Person Update V1 api to disable the user as a workaround. If users are synced from AD, it is recommended to disable the user instead of deleting it.
If you still need to delete the user, use the Repository api: https://docs.alfresco.com/5.0/references/RESTful-PersonPersonDelete.html
Value | Description |
---|---|
json | The default response format |
admin | The authentication access |
required | The transaction level |
argument | The format style |
Example:
HTTP DELETE Request: http://localhost:8080/alfresco/service/api/people/testUser
Note that, only users with admin role can create/update/delete users and groups.
Hello,
I need to delete user anyway, I tried via interface but there is an error,
so , i tried via API indicate in this forum, but i have another error message.
Error via interface :
"message" : "07260136 Wrapped Exception (with status template): 07260803 Failed to execute script 'classpath*:alfresco/templates/webscripts/org/alfresco/repository/person/person.delete.js': Node does not exist: workspace:/\/SpacesStore\/561b834d-4f27-4bb2-aaee-9e700c7d5c4a (status:Status[id=1255changeTxnId=7668b62b-6c3f-45d7-94b4-cf315cff4709, dbTxnId=138, deleted=true])"
Error via API :
{ "status": { "code": 500, "name": "Internal Error", "description": "An error inside the HTTP server which prevented it from fulfilling the request." }, "message": "07260177 Wrapped Exception (with status template): 07260897 Failed to execute script 'classpath*:alfresco/templates/webscripts/org/alfresco/repository/person/person.delete.js': Node does not exist: workspace://SpacesStore/561b834d-4f27-4bb2-aaee-9e700c7d5c4a (status:Status[id=1255changeTxnId=7668b62b-6c3f-45d7-94b4-cf315cff4709, dbTxnId=138, deleted=true])", "exception": "", "callstack": [], "server": "Community v7.0.0 (rdf924796-blocal) schema 14,002", "time": "Aug 26, 2021, 2:23:30 PM" }
I also tried via admin-nodebrowser
and have this error message : 13:45:30 - 07260881 beforeDeleteNode: use PersonService to delete person
Have you any idea to correct it ?
Thanks!
@PierreP As mentioned above there are no ootb V1 api for delete person. Repo api should still work though.
DELETE http://localhost:8080/alfresco/service/api/people/{USERName}
Example http delete method for delete person:
http://localhost:8080/alfresco/service/api/people/test2
Make sure you provide the correct username you want to delete.
You can also write a custom webscript to delete the person if at all required with PersonService
Thanks @abhinavmishra14 for your response,
I use the api like you say, the username is linked to the "id" column in alfresco right ? (in our case, it's the email address)
my call :
curl --location --request DELETE 'https://alfresco-beta.xxx.local/alfresco/service/api/people/aze@aze.fr' \ --header 'Authorization: Basic (not in the web but it's admin:password)'
have you got some clues to write a web script ?
(because in interface i have an error when i want use javascript console if it is the way to do that (cf screenshot))
Thanks,
Pierre
That's strage. It should work irrespective of email unless email is used as username/userId.
This both requests worked fine for a test i did:
curl -X DELETE -H "Authorization: Basic VElDS0VUXzYxYmIwMmM3Y2I3NzQxOTM2MWM1YzY3ZWViY2RmODdiMDcyMDVmMjU=" http://localhost:8080/alfresco/service/api/people/test2
curl -X DELETE -H "Authorization: Basic VElDS0VUXzYxYmIwMmM3Y2I3NzQxOTM2MWM1YzY3ZWViY2RmODdiMDcyMDVmMjU=" http://localhost:8080/alfresco/service/api/people/test@alfresco.com
Are you getting the error for specific user or all users? Can you try any other users? Try creating a test user and see what you get ? Are these users synced from ldap/ad?
If you are getting the error with default api, likely you would get same with any custom webscript as well.
You can learn writing webscript from here: http://ecmarchitect.com/alfresco-developer-series-tutorials/webscripts/tutorial/tutorial.html
Here is an example if this helps:
public class DeleteUserWebscript extends AbstractWebScript { private static final Logger LOGGER = LoggerFactory.getLogger(DeleteUserWebscript.class); private final PersonService personService; public DeleteUserWebscript(final ServiceRegistry serviceRegistry) { super(); this.personService = serviceRegistry.getPersonService(); } @Override public void execute(final WebScriptRequest req, final WebScriptResponse res) throws IOException { final String userName = req.getParameter("username"); LOGGER.info("Deleting user: {}", userName); try { if (personService.personExists(userName)) { personService.deletePerson(userName); res.getWriter().write(String.format("User %s has been deleted successfully!", userName)); } else { final String errorMsg = String.format("User %s can not be found, unable to delete the user!", userName); LOGGER.info(errorMsg); res.getWriter().write(errorMsg); res.setStatus(404); } } catch (AuthenticationException authex) { LOGGER.error("Failed to authenticate user", authex); res.getWriter().write(String.format("Failed to delete the user %s due to: %s. Please contact administrator!", userName, authex.getMessage())); res.setStatus(401);
} catch (AlfrescoRuntimeException excp) { LOGGER.error("Error while deleting the user", excp); res.getWriter().write(String.format("Failed to delete the user %s due to: %s. Please contact administrator!", userName, excp.getMessage())); res.setStatus(500);
} } }
<webscript> <shortname>Delete User</shortname> <description></description> <url>/support-admin/delete-user?username={username}</url> <authentication>admin</authentication> <family>ADMIN_UTILS</family> </webscript>
<bean id="webscript.com.demo.admin.delete-user.delete" class="com.demo.admin.webscript.DeleteUserWebscript" parent="webscript"> <constructor-arg ref="ServiceRegistry"/> </bean>
Hello,
Thanks again for your help @abhinavmishra14 ,
I tried with all user of my instance of Alfresco and i get the same error ...
Thanks for your documentation of webscript, i will try this even if you said maybe it don't works.
If it's don't work again, i think i will wait an update of Alfresco, and just desactivate user (even if it's not really clean).
Pierre.
Ideally we deactivate the users in production systems instead of deleting them. Usually delete api causes issues with users synced from outside of the repository such as ldap/ad. I am not sure about your case though. From what i could recall, when you sync users from ladp/ad, there is property called "isMutable" is set to false which means that user cannot be deleted.
You can also use this api : http://127.0.0.1:8080/alfresco/service/api/people/<userName>
and see what you get for your users which are not getting deleted. Its just another debug step.
e.g.: http://127.0.0.1:8080/alfresco/service/api/people/test@alfresco.com
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.