grahamr975 / EWS-Office365-Contact-Sync

Uses Exchange Web Services to synchronize a Global Address List in Office 365 to a user's mailbox
MIT License
96 stars 21 forks source link

single User sync works / DIRECTORY sync fails #32

Closed mandelbrotmedia closed 3 years ago

mandelbrotmedia commented 3 years ago

Hi!

if syncing a single user everything works. when syncing all users with DIRECTORY flag i got the following error:

ERROR Failed to Sync-ContactList for user@mydomain.com Failed verify that MY COMPANY contacts exists for user@mydomain.com

also getting 404 and 503 errors

grahamr975 commented 3 years ago

Does the account you're running it from have Exchange application impersonation permissions? Even with an admin account, you need this.

mandelbrotmedia commented 3 years ago

Yes, the account has application impersonation rights. Found out if i run the script at 9:00 everything works fine. if i run the script at night at 2:00 i get 404 or 503 error on every mailbox.

I think its a microsoft thing

grahamr975 commented 3 years ago

Can you verify that the necessary Office 365 URLs are whitelisted in your environment? All Microsoft 365 Common URLs with ID#56 on the following page should be allowed: https://docs.microsoft.com/en-us/microsoft-365/enterprise/urls-and-ip-address-ranges?view=o365-worldwide

grahamr975 commented 3 years ago

Closing due to lack of reply...