We seem to be running into an issue with Secure Tokens. Searching has made me realize this is something most people are having difficulty with but it's usually with the Admin account not having a token but ours is sometimes the other way around.
Long story short a second admin account that was added during the enrollment stage was getting the token then other users logging into the device would not get a token, now really showing itself with updates and the users getting a "You need to be an owner" error.
So I created a script to run from Self Service that just prompts the user for their password then runs the command and passes the credentials of the Admin with the secure token. However, it always errors out saying the users password is incorrect but when I test and run the same thing from the terminal on the test device it works fine. Is there something I'm missing here? Does apple do something to restrict this kind of access from a script?
#!/bin/bash
# Prompt the user for their username and password using AppleScript
osascript <<EOD
set userPass to text returned of (display dialog "Enter your password:" default answer "" with hidden answer)
EOD
# Run sysadminctl
sysadminctl -secureTokenOn $3 -password $userPass -adminUser $4 -adminPassword $5