DEV Community

Miro
Miro

Posted on

Downloading GAL as individual vCards using OWA

Some time ago, a friend asked me about syncing Exchanges's GAL (Global Address List) with a mobile phone. So I started looking into Exchange Web Services, but as it turns out I need GAL id in order to query it. And to get it I need either more privileged access to Office 365 tenant or snoop OWA's traffic as described in the article: https://gsexdev.blogspot.com/2013/05/using-ews-findpeople-operation-in.html

Looking at the network log in a browser I figured that I could effectively do everything within a browser ran from Puppeteer and send it to Radicale CardDAV server.

But as it turned out, one required field, "Pager", was not present in Exchange's Persona object. So good old "copy everything from GAL into Contacts" worked, at least for one-off sync, and this idea was abandoned.

Here is JavaScript PoC that can be used to download GAL as vCard files. Bear in mind that it doesn't have any error handling and might not work in every browser. It works in Chrome. Generated vCards are not 100% by specification since I'm serializing whole persona object into it, but I haven't had any issue opening it in Windows (People app), Outlook or on iOS/Android phones.

Before posting this I just cleaned up code a bit and replaced XHR with fetch.

How to use in 5 steps:

  1. Open https://outlook.office365.com/people/ in a browser and sign in with your O365 account
  2. Open browser's console
  3. Paste this script
  4. Run one of the functions, suggestion is to test with OwaGalExtractor.downloadGal(null, 5)
  5. Look at a bunch of file being downloaded (chrome might ask you to allow multiple file download)

Top comments (0)