Managing Cloud Pak for Data users by command line

The cpd-cli user-mgmt command line interface can manage Cloud Pak for Data users and user groups, and import LDAP users.

Before you run any cpd-cli user-mgmt commands, ensure that:

The following commands use an example profile named default. Alternatively, you can manage users from the Cloud Pak for Data client instead.

Manage users

To list all of the users in Cloud Pak for Data, including their usernames, roles, and e-mail addresses:

cpd-cli user-mgmt list-users --profile default --output type

For the output type, you can specify json, text, or yaml. The default output type is text.

To retrieve details on a Cloud Pak for Data user:

cpd-cli user-mgmt get-user username --profile default --output type

For the output type, you can specify json or yaml. The default output type is json.

To add or update an existing Cloud Pak for Data user with parameters from a JSON file:

cpd-cli user-mgmt upsert-user username --data user.json --profile default

By default, new roles are always added to the existing roles. To overwrite the exiting roles of a user instead, append the --replace-roles flag.

Example of a user JSON file:
{
   "username":"chec9",
   "displayName":"chec",
   "email":"chec@ibm.co",
   "user_roles":[
      "zen_user_role"
   ],
   "password":"password"
}

Alternatively, to add or update multiple Cloud Pak for Data users with parameters delimited by commas from a CSV file:

cpd-cli user-mgmt bulk-upsert-users --from-csv-file bulkUsers.csv --profile default
Example of a multiple user CSV file:
username,password,email,displayName,user_roles
tim,pass,tim@test.com,timothee,zen_administrator_role;zen_user_role
keshav999,pass,k@test.com:wq,Keshav,zen_user_role
monil99,past,monil@test.com,Monil,
Tom,12345,tom@test.com,Tim,zen_administrator_role zen_user_role

Manage user groups

To list all of the user groups in Cloud Pak for Data:

cpd-cli user-mgmt list-groups --profile default

To retrieve details on a Cloud Pak for Data user group:

cpd-cli user-mgmt get-group group-name --profile default

To add or update an existing Cloud Pak for Data user group with parameters from a JSON file:

cpd-cli user-mgmt upsert-group --data group.json --profile default

By default, new roles are always added to the existing roles. To overwrite the exiting roles of a user group instead, append the --replace-roles flag.

Example of a user group JSON file:
{
    "name": "Trial1",
    "description": "Upsert group test",
    "role_identifiers": ["zen_developer_role", "wkc_data_scientist_role"]
}

Import LDAP users and user groups

To configure LDAP with parameters from a JSON file:

cpd-cli user-mgmt config-ldap --config ldap-config.json --profile default
Example of an LDAP configuration JSON file:
{
  "externalLDAPHost": "ldap://9.87.654.321",
  "externalLDAPPort": 389,
  "externalLDAPSearchBase": "dc=wdp,dc=com",
  "externalLDAPSearchField": "cn",
  "externalLDAPSearchUser": "jdoe@wdp.com",
  "externalLDAPSearchPassword": "XXXXXXXXX"
}

To add an LDAP user to a Cloud Pak for Data user group:

cpd-cli user-mgmt add-ldap-user-to-cpd-group --ldap-user ldap-user --group cpd-group --profile default

To add an LDAP group to an existing Cloud Pak for Data user group:

cpd-cli user-mgmt add-ldap-group-to-cpd-group --ldap-group ldap-group --group cpd-group --profile default