Creating user accounts in a batch by using shell scripts
Location of shell scripts
The shell scripts are stored in a subfolder of the BMC Digital Workplace Catalog installation folder, by default, /opt/bmc/digitalworkplace. The scripts are located in installLocation/sb/rxscripts.
The scripts in the rxscripts folder reference the following system scripts:
Script name and location | Description |
---|---|
./bin/setenv.sh | Sets the environment variables. Make sure that the values in this file match those in your system. This script must be run by prepending source as the current context. |
./bin/login.sh {user} {password} | Logs in as the specified user. |
./bin/users/create.sh {user_info.json} | Creates the user by reading the specified JSON file. |
If the scripts are in the specified locations, proceed to the next section.
User account text files for shell scripts
A user account file is a set of key=value pairs encoded as a JSON object in a text file. Create the user text file on the server in installLocation/sb/rxscripts so that the user creation script can read it. Each file must contain the required information for a single user as a JSON string.
Example: To create a self-service request user account for Bob Baxter, compose the following text file and save it as bob_baxter.json:
"fullName": "Bob Baxter",
"loginName": "Bob@${rx_tenant_domain}",
"emailAddress": "Bob@${rx_tenant_domain}",
"licenseType": "Read",
"groups": ["sbe-myit-users"],
"forcePasswordChangeOnLogin": "false",
"password": "Passw0rd!"
}
For more example JSON text files you can use to create accounts, see Example JSON text files with the information to create user accounts below.
To create a user account with a script
This procedure creates the user account from a JSON text file, such as the example in User account text files for shell scripts above.
- On the BMC Digital Workplace Catalog server, go to installLocation/sb/rxscripts
Run the source ./bin/setenv.sh command to load the environment variables into the current shell context.
Examplesource ./bin/setenv.shRun the ./bin/login.sh command and pass the parameters to log in as the tenant administrator.
Example./bin/login.sh hannah_admin@calbroservices.com Passw0rd!- A successful login will display a login token composed of a long string of characters.
- An unsuccessful login will display a JSON error message.
For each JSON file, run the ./bin/users/create.sh command to load the specified JSON file to create user accounts.
Example./bin/users/create.sh ./system_notifications.jsonThe system notifies you when the account is successfully created or if the process failed.
To create multiple user accounts with a script
The following script runs a loop to create several users at once from the JSON files that are saved in the installLocation/sb/rxscripts/data/users/myit_users folder.
- On the BMC Digital Workplace Catalog server, go to installLocation/sb/rxscripts
Run the source ./bin/setenv.sh command to load the environment variables into the current shell context.
Examplesource ./bin/setenv.shRun the ./bin/login.sh command and pass the parameters to log in as the tenant administrator.
Example./bin/login.sh hannah_admin@calbroservices.com Passw0rd!Run a for loop on the command line to create a user record for each JSON file in the folder.
Examplefor i in `ls ./data/users/myit_users`;do ./bin/users/create.sh ./data/users/myit_users/$i;done;
Example JSON text files with the information to create user accounts
When you create user accounts with shell scripts, the JSON files should follow the format of the code blocks in this section.
- Required user for system notifications
- Standard user for requests
- Administrative roles to manage service catalogs
- Service agent role to view the service requests of other users
Required user for system notifications
"fullName": "System Notification Account",
"loginName": "sys_notification@${rx_tenant_domain}",
"emailAddress": "sys_notification@${rx_tenant_domain}",
"licenseType": "Read",
"groups": ["sbe-myit-users"],
"forcePasswordChangeOnLogin": "false",
"password": "5Y5_n0tification!"
}
Standard user for BMC Digital Workplace requests
"fullName": "Bob Baxter",
"loginName": "Bob@${rx_tenant_domain}",
"emailAddress": "Bob@${rx_tenant_domain}",
"licenseType": "Read",
"groups": ["sbe-myit-users"],
"forcePasswordChangeOnLogin": "false",
"password": "Passw0rd!"
}
Administrative roles to manage service catalogs
Users who are given access to log in to the BMC Digital Workplace Catalog console can also be granted Administrator rights. The Administrator permission group enables a user to log in to Remedy Mid Tier to perform administrative functions on the BMC Digital Workplace Catalog server.
"fullName": "Mary Mann",
"loginName": "Mary@${rx_tenant_domain}",
"emailAddress": "Mary@${rx_tenant_domain}",
"licenseType": "Fixed",
"groups": ["Administrator", "sbe-catalog-admins"],
"forcePasswordChangeOnLogin": "false",
"password": "Passw0rd!"
}
"fullName": "Ian Plyment",
"loginName": "Ian@${rx_tenant_domain}",
"emailAddress": "Ian@${rx_tenant_domain}",
"licenseType": "Fixed",
"groups": ["Administrator", "sbe-internal-suppliers"],
"forcePasswordChangeOnLogin": "false",
"password": "Passw0rd!"
}
"fullName": "Francie Stafford",
"loginName": "Francie@${rx_tenant_domain}",
"emailAddress": "Francie@${rx_tenant_domain}",
"licenseType": "Fixed",
"groups": ["Administrator", "sbe-asset-managers"],
"forcePasswordChangeOnLogin": "false",
"password": "Passw0rd!"
}
Service agent role to view the service requests of other users
"fullName": "Jim Serven",
"loginName": "Jim@${rx_tenant_domain}",
"emailAddress": "Jim@${rx_tenant_domain}",
"licenseType": "Fixed",
"groups": ["Administrator", "sbe-catalog-agents"],
"forcePasswordChangeOnLogin": "false",
"password": "Passw0rd!"
}
For more information about the fields to be set, see Overview-of-user-accounts-and-groups-for-BMC-Digital-Workplace-Catalog.