Microsoft Outlook 2016 for Mac would randomly but repeatedly prompt me to enter my username and password. We as well do have the Exchange on prem. Installed and the newest version of Outlook for mac 16.14., but the script you posted does not work for me and I’m getting the following error. While the outlook search in background was blank, i opened up spotlight. I then keyed in same search for a contact. It was not showing that it was indexing. It thought about it for what seemed like 20 seconds, then things started to come up. Then a few seconds later the outlook search in the background burst into life. I then went into search contacts.
To everyone else reading this. I have worked for about an hour with Moshe on this, we got around it by cheating and just using his universities IMAP server instead. It looks like his university uses an expired SSL certificate which despite forcing trust on it, it just isn't working. To answer your question, I first need to say it isn't possible to connect mail to OWA (well, old versions used it for public folders, but, that's another story). What you want to do is connect mail to Exchange.
Outlook Web Access is just the name for the Exchange web interface, and, you do not connect applications to it. If you easily set it up on iOS, this was most likely down to choosing Exchange as the server type. The latest version of OSX's Mail does have support for Microsoft Exchange 2010 now, and I am unsure as to why you are having problems. All I can suggest is that you make sure your server type is set to Exchange and you set the settings correctly.
Just Googled for a picture, please again, double check that you did set the Exchange mode, it should look something like this. The reason this doesn't work natively (most likely) is that the university is still using an older version of Exchange. Apple Mail and consequently the new version of Outlook for Mac will only connect to an Exchange server running EWS(Exchange Web Services). This is a drastic change from the older OWA style present in the 2003 variants of Exchange. What I do to circumvent this limitation is use a mail proxy.
The one I use is DavMail. Essentially DavMail works as a broker between the Exchange server and your client. You can also set it to disregard validation of certificates enabling you to get around your certificate issue. You will simply connect to DavMail (localhost) using IMAP and SMTP and then DavMail will broker the connection to server.
This also gives you native access to your Calendaring and Contacts on Exchange. Hope this helps.