Posted on 04-24-2023 02:51 AM
04-24-2023 09:36 AM - edited 04-24-2023 09:37 AM
In order to give your users secure token rights it will either require user interaction or for you to know their passwords. We use something like this with user interaction:
#!/bin/bash
###############################################################################################################
## This Script will enable the secure Token on LDAP Accounts on Macs with an account that has a secure token ##
## This will only work if the LDAP User is logged in, and requires user interaction to enter their password ##
###############################################################################################################
loggedInUser=$(stat -f %Su /dev/console)
UserPWD="$(osascript -e 'Tell application "System Events" to display dialog "Please Enter your Password:" default answer "" with hidden answer' -e 'text returned of result' 2>/dev/null)"
sysadminctl -adminUser YOURADMINUSER -adminPassword YOURADMINSUSERPASSWORD -secureTokenOn $loggedInUser -password $UserPWD