Modifying settings of users

You can modify user settings, including the user name, roles, and assigned resource groups. Changing the password requires a different type of request. See Changing a user password.

Method and URI

To update the user {userId}, use a PUT method and a URI:

PUT     https://{hostname|IP}/api/security/user/{userId}

Tip

To get a {userId} value based on the user name, follow the instructions in Getting a {userId}.

Parameters

None.

Data

You can use the data key-value pairs that are described in Adding an individual user or Adding users that are based on an LDAP group. To update the password of an individual user, see Changing a user password.

Example 1: Modify settings for an individual user

Assume that you have the following individual user:

  • Username: Sarah (userId: 1005)

  • Roles:

    • Backup Only

    • Self Service.

  • Resource groups:

    • Hypervisor All Resource Group

    • BlueMachines - Dallas

You want to modify these user settings as shown:

  • Name: Sarah Wiseman

  • Role: SYSADMIN

  • Resource group: All Resources

A Python snippet that is similar to the following example can be used to update the individual user settings:

user_id = "1005"    # Sarah (an individual user)

_data = f'''{{
    "name":        "Sarah Wiseman",
    "permissions": [
        {{
            "resourcePoolId": "1002",
            "roleIds":        ["1001"]
        }},
        {{
            "resourcePoolId": "1000",
            "roleIds":        ["1001"]
        }}
    ]
}}'''

requests.put('https://' + spp_ipv4 + '/api/security/user/' + user_id,
     headers={...}, data=_data, verify=...)
_images/reference_user_update02.png

Figure 85 The same action can be taken in the IBM Spectrum Protect Plus web user interface: In the navigation pane, click Accounts > User, click the user to update from the list, click the ellipsis (···) > Modify settings. To update only the resource group of this user, click Modify resources.

_images/reference_user_update03.png

Figure 86 Modifying the resource group settings.

After you run the Python snippet, ensure that you get a response with the HTTP status of 200 (OK) and that the user is updated.

Example 2: Modify settings of a user that is based on an LDAP group

Assume that you added the user, Sales-Americas ({userId} 1006), to IBM Spectrum Protect Plus. The user is based on an LDAP group. You want to modify the settings as below:

  • Role: SYSADMIN ({roleId} 1001)

  • Resource group: All Resources ({resourcePoolId} 1001)

A Python snippet that is similar to the following example can be used to modify the settings of the LDAP group user:

user_id = "1006"    # Sales-Americas (an LDAP group)

_data = f'''{{
    "permissions": [
        {{
            "resourcePoolId": "1001",
            "roleIds":        ["1001"]
        }}
    ]
}}'''

requests.put('https://' + spp_ipv4 + '/api/security/user/' + user_id,
    headers={...}, data=_data, verify=...)
_images/reference_user_update04.png

Figure 87 For an LDAP group user, you can modify roles and resource groups.

After you run the Python snippet, ensure that you get a response with the HTTP status of 200 (OK) and that the user is updated.