Bulk Update the Enrollment User (auth_username) using API
What
This problem and solution came from a customer who had many devices in FileWave, yet did not have the 'Enrollment User' (internally known as auth_username) populated. In order for automatic associations of iPads with Apple Classroom, devices must have an enrolment user set. While it’s possible to set these one by one, that does not scale well. Even hosted customers could benefit from this example. It can set the Enrollment User for both iOS as well as macOS devices in FileWave.
When/Why
The below solution leverages the FileWave Anywhere API (v2) and is a great example that any customer could build. You can run this script from your mac, Windows, or Linux computer, and it will talk to the API and make the changes in bulk.
This example happens to be a Python script. As such, if ran on the FileWave Server, Python will already be installed. However, for hosted customers, the script will not be ran on the server and it should be necessary to have Python installed on the device running this script. We have also included a zsh script which may be easier for someone to modify or use.
https://www.python.org/downloads/
https://docs.python.org/3/using/windows.html
How
- The first step is to download the script:
Bulk Update Enrollment User.zip
-
Once downloaded, the zip contains three files: bulk_change_device_authname.py, bulk_change_device_authname_updated.zsh and auth_username.csv and you can run either the .py or the .zsh script as they will do the same thing.
-
If the Python script is not being ran directly on a FileWave Server, it may be necessary to alter the first line of code, to specify the location of Python on the device running the script. For example, on macOS, that may be: #/usr/local/bin/python3
- If you do not have python installed, you may use the updated shell script. The README text file will have the updated instruction guide on using the shell script.
-
The CSV file should be edited to include the desired list of Devices with Users. The supplied template looks like:
Device ID,Enrollment Username
67d6f4bfcf27fa62bb9815365c67ebf7fed8f9c3,test
An Inventory query could be used to obtain the list of Device IDs. Note, the script is only expecting two columns in the order of Device ID and Enrollment Username.
It may assists to initially export additional columns to assist with device identification, but after adding the usernames, be sure to remove any of these additional columns in the CSV file.
- Obtain the desired users base64 Application Token from the FileWave Administrators Assistant view
The following commands may now be executed on macOS or Linux (a similar command could be executed on Windows) to action the process.
Python script command:
./bulk_change_device_authname.py --token {b5cb89a0-fe59-4cb1-9359-d72b79369c0} --host ExampleCo.filewave.net --mapping ./auth_username.csv
Updated shell script command:
./bulk_change_device_authname_updated.zsh --host your.filewave.net --token {your_API_token} --mapping ./auth_username.csv
The script will give you feedback about the success or failure of any records.
Python Imports
The beginning of the Python script has a list of imports:
import argparse
import base64
import csv
import os
import re
import requests
import sys
If any are missing, e.g 'requests', it should be necessary to instal them. The script should report such an error if any are missing when ran. Some are available on a default Python setup.
It is possible to instal any missing. For example, on macOS or Linux, the command may appear as (depending upon the location of Python)
/usr/local/bin/python3 -m pip install requests
Hopefully the script at this point has been successful and can be see as a great example of bulk actions.
No comments to display
No comments to display