Script to modify to add site exceptions

New Contributor

I apologize if these questions seem simple but I am still pretty new to scripting and to using JAMF.

My organization needs to whitelist several domains in Google to allow for Single Sign On. Running the script below while logged in as the user will add the sites:

defaults write AuthServerWhitelist ""
defaults write AuthNegotiateDelegateWhitelist ""

Obviously, * gets replaced with the sites we need added.

Below is the script we have tried using through JAMF:


Get the logged in username

loggedInUser=$(stat -f%Su /dev/console)

Run command as user

sudo -u $loggedInUser /usr/bin/defaults write /Users/$loggedInUser/Library/Prefences/ AuthServerWhitelist ""
sudo -u $loggedInUser /usr/bin/defaults write /Users/$loggedInUser/Library/Prefences/ AuthNegotiateDelegateWhitelist ""

The settings are not being written to the file after the script runs. I have done some research about running the script as the user and have had no luck finding a solution.

Any suggestions are greatly appreciated.




Valued Contributor II

No need to run your script as the logged in user. Just run it with a login trigger, use $3 for the current user and then chown the file when you're done.


defaults write /Users/$3/Library/Preferences/ AuthServerWhitelist "*"
chown $3 /Users/$3/Library/Preferences/

Esteemed Contributor III

Configuration Profile is mucho bueno for this kind of thing.


Not applicable

We did it with Configuration Profile with custom payload, uploading a PLIST.