ExtensionAttributes
ExtensionAttributes copied to clipboard
Office365_Logons.xml - check if the DB file exists first
You should check to see if the MicrosoftRegistrationDB.reg file exists first before trying to read from it. If a user hasn't logged on and had the file created yet, it will give an error when running the script, similar to:
Error: unable to open database "/Users/user/Library/Group Containers/UBF8T346G9.Office/MicrosoftRegistrationDB.reg": unable to open database file
I updated the code to the following:
# check if the registry file exists if [[ -e "$HOMEPATH/Library/Group Containers/UBF8T346G9.Office/MicrosoftRegistrationDB.reg" ]] then # execute some sql to get the active O365 logon, if any local RESULT=$(/usr/bin/sqlite3 "$HOMEPATH/Library/Group Containers/UBF8T346G9.Office/MicrosoftRegistrationDB.reg" "SELECT value from HKEY_CURRENT_USER_values WHERE name='UserDisplayName' LIMIT 1;") # checks to see if we got a hit if [ "$RESULT" != "" ]; then logons+="$RESULT;" fi fi