Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Mar 5, 2024 3:58:31 AM
Feb 23, 2024 5:18:12 AM
Using the qlik-cli it is possible to import a list of users to a tenant from a csv file.
It will be then possible to assign roles, entitlements and space permissions to the users before they log in to the tenant.
Here's a possible example of how to do that.
Name,Email
Mick Case,Mick.Case@example.com
Davide Bironi,Davide.Bironi@example.com
Kenny Handsley,Kenny.Handsley@example.com
Leigh Kersriver,Leigh.Kersriver@example.com
Gerry Vain,Gerry.Vain@example.com
Tommy Ioni,Tommy.Ioni@example.com
Terence Attendant,Terence.Attendant@example.com
John Oughborne,John.Oughborne@example.com
William Guard,William.Guard@example.com
Renato Padovano,Renato.Padovano@example.com
# Import the csv file as an array of objects
$csv = Import-Csv -Path userlist.csv
# Initialize a counter for the subject
$counter = 1
# Loop through each object in the array
foreach ($row in $csv) {
# Generate the subject using the counter
$subject = "ExampleSubject" + $counter
# Execute the qlik-cli command with the column values and the subject
qlik user create --name $row.Name --email $row.Email --subject $subject
# Increment the counter
$counter++
}
#!/bin/bash
# Get the number of lines in the csv file
lines=$(wc -l < userlist.csv)
# Loop from the second line to the last line (skipping the header row)
for ((i=2; i<=lines; i++))
do
# Get the name and email values from the ith line using cut
name=$(cut -d, -f1 userlist.csv | sed -n "${i}p")
email=$(cut -d, -f2 userlist.csv | sed -n "${i}p")
# Generate the subject using the counter
subject="ExampleSubject$counter"
# Execute the qlik-cli command with the column values and the subject
qlik user create --name "$name" --email "$email" --subject "$subject"
# Increment the counter
((counter++))
done
NOTE: users will be created with a temporary SubjectId like "ExampleSubject1", "ExampleSubject2", and so so on. After the first login, users will get a proper SubjectId.
Roles, entitlements and space permissions will follow the users to the new subject.
Alternatives ways of adding users via scripts might be achieved via the an /api/v1/users CALL with the POST method and a payload like:
PAYLOAD:
{
"email": "name@example.com",
"name": "First Lastname",
"subject": "SubjectXYZ"
}
The information and the files in this article are provided as-is and will be used at your discretion. Depending on the tool(s) used, customization(s), and/or other factors, ongoing support on the solution below may not be provided by Qlik Support.
Hello.
Please tell me about the following message.
>It will be then possible to assign roles, entitlements and space permissions to the users before >they log in to the tenant.
As shown in the attached capture, I edited the csv file and PS1 file and ran it, but an error appeared and I could not run it.
Please provide specific examples of assigning roles, qualifications, and space permissions.
I'm using a translation, so I'm sorry if the English is hard to understand.
We apologize for any inconvenience this may cause and appreciate your understanding.
▼csv
▼PSImportUsers.ps1
▼Error
-----------------------------------------------------
Error: {
"traceId": "19c53014a34ead2c7fe8753d82654bc3",
"errors": [
{
"code": "IDENTITIES-11010",
"detail": "validation error: unable to match all requested documents for field \"roles\"",
"meta": {
"numExpected": 1,
"numFound": 0
},
"source": {
"pointer": "/roles"
},
"status": 400,
"title": "Bad Request"
}
]
}
Hi @ksuto ,
I see a typo in your csv file: "Proffesional", instead than "Professional"
That could be the cause.
I edited the misspelling of Professional, but it didn't work.
I think there may be an error in the "Flags" information in the capture below and the content added to the csv or PS1 file.
Which flag should I use for "TenantAdmin" and "Professional"?
Hi @ksuto : I did some testing. For roles like "TenantAdmin" the flag to use is "--role"
Entitlements, however, cannot be assigned using the "user" command.
You will need to use the "license" one.