Hi, please remember in Jamf it runs any policy as root not as a user so to get a script to run as a user do this:
# Get current logged in user
curUser="`stat -f%Su /dev/console`"
#Run script as user
sudo -u $curUser osascript <<'END'
tell application "Microsoft Outlook"
set exList to get every exchange account
repeat with exItem in exList
set exDomain to get server of exItem
if exDomain is "https://OurServer.org/EWS/Exchange.asmx" then
set ldap server of exItem to "ldap.OurServer.org"
set ldap port of exItem to 3269
set ldap use ssl of exItem to true
end if
end repeat
end tell
END
Hi, please remember in Jamf it runs any policy as root not as a user so to get a script to run as a user do this:
# Get current logged in user
curUser="`stat -f%Su /dev/console`"
#Run script as user
sudo -u $curUser osascript <<'END'
tell application "Microsoft Outlook"
set exList to get every exchange account
repeat with exItem in exList
set exDomain to get server of exItem
if exDomain is "https://OurServer.org/EWS/Exchange.asmx" then
set ldap server of exItem to "ldap.OurServer.org"
set ldap port of exItem to 3269
set ldap use ssl of exItem to true
end if
end repeat
end tell
END
Yes, you're right, but somehow this is working without running it as user. It enables SSL but still throws the following error:
Script result: 252:306: execution error: Microsoft Outlook got an error: The user name of the account is required. (-1715)
I just tested this script and it worked for me. How are you testing this?
I just tested this script and it worked for me. How are you testing this?
I run it like this:
#!/bin/bash
# Get current logged in user
curUser="`stat -f%Su /dev/console`"
# Run script as user
sudo -u $curUser osascript <<'END'
tell application "Microsoft Outlook"
set exList to get every exchange account
repeat with exItem in exList
set exDomain to get server of exItem
if exDomain is "Server" then
set ldap server of exItem to "Server"
set ldap port of exItem to 3269
set ldap use ssl of exItem to true
end if
end repeat
end tell
END
Sorry, let me clarify. I meant how are you testing this script? Are you running locally to test or in Jamf?
Sorry, let me clarify. I meant how are you testing this script? Are you running locally to test or in Jamf?
Ah, I use a policy, available in self service, which calls the script
Is an Outlook profile already existing when you tested this?
Is an Outlook profile already existing when you tested this?
Yes, there is an active profile when testing.
Alright. I got it. :)
#!/bin/sh
#Get current User
currentuser=$(scutil <<< "show State:/Users/ConsoleUser" | awk '/Name
&& ! /loginwindow/ { print $3 }')
echo $currentuser
#Runs Apple Script with current User
sudo -u $currentuser /usr/bin/osascript -e 'tell application "Microsoft Outlook" to set properties of exchange account 1 to {ldap server:"XXX", ldap use ssl:true, ldap port:"3269"}'
@Tim_Apple How do you configured the outlook account? Do you authenticate with name and password or Kerberos? I cant get it work when I have an account that is configured with Kerberos,