Managing Cloud Pak for Data users with the command line

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

Before you begin

Before you run any cpd-cli user-mgmt commands, complete the following prerequisites.

Managing users

To list all users in Cloud Pak for Data, including their usernames, roles, and email addresses, use the following command.

cpd-cli user-mgmt list-users --profile ${CPD_PROFILE_NAME} --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, use the following command.

cpd-cli user-mgmt get-user username --profile ${CPD_PROFILE_NAME} --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, use the following command.

cpd-cli user-mgmt upsert-user username --data user.json --profile ${CPD_PROFILE_NAME}

Supply a user.json file that is similar to the following example.

{
   "username":"chec9",
   "displayName":"chec",
   "email":"chec@ibm.co",
   "user_roles":[
      "zen_user_role"
   ],
   "password":"password"
}

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.

Alternatively, to add or update multiple Cloud Pak for Data users with comma-separated parameters in a CSV file, use the following command.

cpd-cli user-mgmt bulk-upsert-users --from-csv-file bulkUsers.csv --profile ${CPD_PROFILE_NAME}

Supply a bulkUsers.csv file that is similar to the following example.

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

Managing user groups

To list all user groups in Cloud Pak for Data, use the following command.

cpd-cli user-mgmt list-groups --profile ${CPD_PROFILE_NAME}

To retrieve details on a Cloud Pak for Data user group, use the following command.

cpd-cli user-mgmt get-group group-name --profile ${CPD_PROFILE_NAME}

To add or update an existing Cloud Pak for Data user group with parameters from a JSON file, use the following command.

cpd-cli user-mgmt upsert-group --data group.json --profile ${CPD_PROFILE_NAME}

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.

Supply a group.json file that is similar to the following example.

{
    "name": "Trial1",
    "description": "Upsert group test",
    "role_identifiers": ["zen_developer_role", "wkc_data_scientist_role"]
}

Importing LDAP users and user groups

To configure LDAP with parameters from a JSON file, use the following command.

cpd-cli user-mgmt config-ldap --config ldap-config.json --profile ${CPD_PROFILE_NAME}

Supply a ldap-config.json file that is similar to the following example.

{
  "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, use the following command.

cpd-cli user-mgmt add-ldap-user-to-cpd-group --ldap-user ldap-user --group cpd-group --profile ${CPD_PROFILE_NAME}

To add an LDAP group to an existing Cloud Pak for Data user group, use the following command.

cpd-cli user-mgmt add-ldap-group-to-cpd-group --ldap-group ldap-group --group cpd-group --profile ${CPD_PROFILE_NAME}