Outlook Exchange Config - Run as Logged in User not Root

ImaSysAdmin
New Contributor

Hi There,

Currently i am using https://github.com/talkingmoose/Outlook-Exchange-Setup-5 to configure the Exchange account for an on premise server. I am trying to authenticate/grab the details of the logged in user instead of via AD or O365.
However, it seems as though when this script gets run from JAMF, it thinks the logged in user is Root/System Administrator, as i believe JAMF runs/deploys the script as root.

Is there a way of scripting launching the apple script as the actual logged in user of the account and not the elevated account?

This is how i call it up:

 

#!/bin/sh

# get the current user
loggedInUser=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ && ! /loginwindow/ { print $3 }' )

# test if a user is logged in
if [ -n "$loggedInUser" ]; then
# get the uid
uid=$(id -u "$loggedInUser")
# do what you need to do
launchctl asuser "$uid" osascript /Users/Shared/Outlook/Outlook\ Exchange\ Setup\ 5.5.4.scpt
fi

exit 0

 

 

Thanks in advance!

1 REPLY 1

talkingmoose
Moderator
Moderator

I haven't tested the script on anything much later than macOS Catalina, but the set of scripts isn't designed to be run by Jamf Pro. They're suppose to be packaged and you deploy the package to place the scripts on your computers.

They sit on the computer and are called by user launch agents, which run as the currently logged in user. If you haven't seen it, be sure to read the wiki to understand how it works and how to deploy.

https://github.com/talkingmoose/Outlook-Exchange-Setup-5/wiki

What I've seen some folks do is take the AppleScript and put it into a Self Service policy to let end uses run themselves. That may be an alternative to consider.