Skip to main content
Solved

Outlook SSL

  • January 14, 2022
  • 11 replies
  • 15 views

Forum|alt.badge.img+7

Hey there,

we're trying to set some advanced settings in Microsoft Outlook. We want to tick the red outlined box and enable SSL.

Right now we're using this script, which work's, but throws an error. I'm not really into scripting but i tried a little bit on my own and came out with the following:

osascript <<END tell application "Microsoft Outlook" set ldap server of exchange account 1 to "XXX" set ldap use ssl of exchange account 1 to yes set ldap port of exchange account 1 to 6666 end tell END

It throws no error, but it won't enable SSL either. I think it's because I don't define the default exchange account and I don't really know how to do it. Shouldn't it be just "exchange account 1"? I tried many things out but I can't get it to work...

Thanks for any help!

Best answer by Tim_Apple

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"}'

 

11 replies

junjishimazaki
Forum|alt.badge.img+10
  • New Contributor
  • 423 replies
  • January 14, 2022

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

 


Forum|alt.badge.img+7
  • Author
  • Contributor
  • 16 replies
  • January 14, 2022

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)


junjishimazaki
Forum|alt.badge.img+10
  • New Contributor
  • 423 replies
  • January 14, 2022

I just tested this script and it worked for me. How are you testing this?


Forum|alt.badge.img+7
  • Author
  • Contributor
  • 16 replies
  • January 14, 2022

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

 

 


junjishimazaki
Forum|alt.badge.img+10
  • New Contributor
  • 423 replies
  • January 14, 2022

Sorry, let me clarify. I meant how are you testing this script? Are you running locally to test or in Jamf?


Forum|alt.badge.img+7
  • Author
  • Contributor
  • 16 replies
  • January 14, 2022

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


junjishimazaki
Forum|alt.badge.img+10
  • New Contributor
  • 423 replies
  • January 14, 2022

Is an Outlook profile already existing when you tested this?


Forum|alt.badge.img+7
  • Author
  • Contributor
  • 16 replies
  • January 17, 2022

Is an Outlook profile already existing when you tested this?


Yes, there is an active profile when testing.


Forum|alt.badge.img+7
  • Author
  • Contributor
  • 16 replies
  • February 9, 2022

Push


Forum|alt.badge.img+7
  • Author
  • Contributor
  • 16 replies
  • Answer
  • May 25, 2022

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"}'

 


Gonzalo
Forum|alt.badge.img+6
  • Contributor
  • 17 replies
  • September 6, 2022

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,