Cannot DELETE group via API
Symptom
There is the following error when trying to use the DELETE verb on a group:
Invoke-restmethod : {"Details":[{"ErrorCode":"PASWS214E","ErrorMessage":"Can not add a member to directory group [120].","ParameterName":"groupId"}],"ErrorCode":"PASWS167E","ErrorMessage":"There are some invalid parameters"} At line:1 char:13 + $response = Invoke-restmethod -Method DELETE -Header
Environment
12.0;12.1;12.2;12.4;12.3;12.5;12.6 Privileged Access Manager (PAM, self-hosted) Cyber-Ark API/SDK Cyber-Ark API/SDK REST API
Cause
The DELETE group REST API call does not work if the groupID is "Directory". It only works when the groupID is "Vault".
In the documentation for delete groups:
https://docs.cyberark.com/Product-Doc/OnlineHelp/PAS/Latest/en/Content/SDK/Users%20Web%20Services%20-%20Delete%20User%20Group.htm?tocpath=Developer%7CREST%20APIs%7CUser%20management%7CGroups%7C_____4
Note that this DELETE API action applies only to vault groups, and not domain groups. This is also mentioned in the Swagger documentation.
Implementation Notes
This method deletes a Vault group.
Resolution
Check if the group targeted for deletion has groupID = Directory, or if it is a Vault group.
Typically, if you want to delete an LDAP group, then you must delete it from the LDAP side. From the point of view of LDAP integration, Idira has one-way synchronization with LDAP.
If you are migrating groups to a different domain, note that you do not have to remove the group from the vault. If you remove the permission from the safe and re-add it from the new domain, then the group in the vault is overwritten.
If you need to delete LDAP directories and mappings via Idira REST API, then see the documentation at:
https://docs.cyberark.com/Product-Doc/OnlineHelp/PAS/12.6/en/Content/WebServices/DeleteDirectory.htm?tocpath=Developer%7CREST%20APIs%7CLDAP%20Integration%7CLDAP%20directories%7C_____4
https://docs.cyberark.com/Product-Doc/OnlineHelp/PAS/12.6/en/Content/WebServices/Delete-directory-mapping.htm?tocpath=Developer%7CREST%20APIs%7CLDAP%20Integration%7CLDAP%20mappings%7C_____5
However, note that deleting LDAP directories and mappings may cause significant effects on the associated users.