Remove a Role for a User

If a user no longer has to perform a task that is associated with a particular role, you can remove that role for that user. In this use case, you will learn how to search for a specific role and remove it for a user.

First, identify the role that you want to remove and then identify the user who's assigned that role.
  1. Use cURL and eq filter parameter with the name field to query. In this example, the queried role name is ORA_PER_HUMAN_RESOURCE_ANALYST_JOB. The role ID returned by the query is 55361929311C580B560EB8BA5C4C1886.
    curl -i -u "<username>:<password>" -H "Content-Type: application/json" -X GET -d <payload> https://servername.fa.us2.oraclecloud.com/hcmRestApi/scim/Roles?filter=name eq "ORA_PER_HUMAN_RESOURCE_ANALYST_JOB"

    Sample Response Payload

    {
      "itemsPerPage": 1,
      "startIndex": 1,
      "Resources": [
        {
          "id": "55361929311C580B560EB8BA5C4C1886",
          "meta": {
            "created": "2009-05-12 11:27:39.226",
            "lastModified": "2016-11-17 17:00:46.000",
            "location": "https://servername.fa.us2.oraclecloud.com/hcmRestApi/scim/Roles/55361929311C580B560EB8BA5C4C1886"
          },
          "schemas": [
            "urn:oracle:apps:scim:schemas:fa:1.0:Role"
          ],
          "name": "ORA_PER_HUMAN_RESOURCE_ANALYST_JOB",
          "displayName": "Human Resource Analyst",
          "description": "Performs duties of a human resources analyst.",
          "category": "JOB",
          "members": [
            {
              "value": "258D2199A0BB1AA3E050F00A185B018E"
            },
            {
              "value": "6424EF8136C0C20F12466257D3540E9C"
            }
          ]
        }
      ]
    }
  2. Now that you have the role ID, search for and get the unique identifier of the user. Use cURL and eq filter parameter with the username field to query. In this example, the queried user name is CUST_CONTRACT_MGR_OPERATIONS. The user ID returned by the query is 5A25572D96277A00C0547E3A715EF682.
    curl -i -u "<username>:<password>" -X GET https://servername.fa.us2.oraclecloud.com/hcmRestApi/scim/Users?filter=username eq "CUST_CONTRACT_MGR_OPERATIONS"

    Sample Response Payload

    {
      "itemsPerPage": 1,
      "startIndex": 1,
      "Resources": [
        {
          "id": "5A25572D96277A00C0547E3A715EF682",
          "meta": {
            "created": "2009-05-25 00:00:00.000",
            "lastModified": "2015-12-14 10:15:48.291",
            "location": "https://servername.fa.us2.oraclecloud.com/hcmRestApi/scim/Users/5A25572D96277A00C0547E3A715EF682"
          },
          "schemas": [
            "urn:scim:schemas:core:2.0:User"
          ],
          "userName": "CUST_CONTRACT_MGR_OPERATIONS",
          "name": {
            "familyName": "Black",
            "givenName": "Sophie"
          },
          "displayName": "Sophie Black",
          "emails": [
            {
              "value": "CUST_CONTRACT_MGR_OPERATIONS@dummy.oracle.com",
              "type": "W",
              "primary": true
            }
          ],
          "roles": [
            {
              "id": "4EB6B72643872425B6BE573B531ABC6B",
              "value": "OKC_CUSTOMER_CONTRACT_MANAGER_VISION_OPERATIONS_DATA",
              "displayName": "Customer Contract Manager - Vision Operations",
              "description": "Customer Contract Manager for Vision Operations"
            },
            {
              "id": "40C4AE052EC2582286A6A0FB1514656C",
              "value": "ORA_PER_EMPLOYEE_ABSTRACT",
              "displayName": "Employee",
              "description": "Identifies the person as an employee."
            },
            {
              "id": "05E9F3576995F83E74EB3818FDCA8639",
              "value": "ORA_PER_LINE_MANAGER_ABSTRACT",
              "displayName": "Line Manager",
              "description": "Identifies the person as a line manager."
            }
          ],
          "active": true
        }
      ]
    }
  3. Using cURL, submit a REMOVE operation of the PATCH request to remove the role for the user. In this example, remove the role ID 55361929311C580B560EB8BA5C4C1886 for the user ID 5A25572D96277A00C0547E3A715EF682 .
    curl -i -u "<username>:<password>"  -H "Content-Type: application/json"  -X PATCH  
    -d {
    "schemas": [
    "urn:oracle:apps:scim:schemas:fa:1.0:Role"
    ],
              "members":[{"value":"5A25572D96277A00C0547E3A715EF682", "operation":"REMOVE"}]
    }
    https://servername.fa.us2.oraclecloud.com/hcmRestApi/scim/Roles/55361929311C580B560EB8BA5C4C1886
    

    The 55361929311C580B560EB8BA5C4C1886 role ID is removed from the 5A25572D96277A00C0547E3A715EF682 user ID.

    Sample Response Payload
    204 - No content