Comments (11)
I got the same issue, issue with modernauth.
if i disable modernauth it connects
!update!
It seems to be happening in:
$AADcredential = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.UserPasswordCredential" -ArgumentList $Credentials.UserName.ToString(), $Credentials.GetNetworkCredential().password.ToString()
$token = [Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContextIntegratedAuthExtensions]::AcquireTokenAsync($Context,"https://outlook.office365.com",$ClientId,$AADcredential).result
$service.Credentials = New-Object Microsoft.Exchange.WebServices.Data.OAuthCredentials($token.AccessToken)
I did notice that the exchange api is now missing in office 365, while this application is calling that api (outlook.office365.com) with guid d3590ed6-52b3-4102-aeff-aad2292ab01c
The strange thing is that negotiaite auth is still working, while i expect Microsoft to first end that type of authentication. before closing the exchange api and forcing us to Graph
from ews-office365-contact-sync.
ModernAuth still works in my environment just fine (Exchange Online). Unfortunately, I don't have the resources or time to test in other environments. Can you confirm that you followed the new README instructions and manually unblocked the included .dll files?
I am thinking of redesigning this script in Graph API, but just don't currently have the time.
from ews-office365-contact-sync.
I have the same issue.
ERROR Failed to Sync-ContactList for [email protected] Cannot convert argument "ctx", with value: "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext", for "AcquireTokenAsync" to type "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext": "Cannot convert the "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext" value of type "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext" to type "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext"."
The weird thing is that it worked fine a couple of days ago.
from ews-office365-contact-sync.
Any update on this ?
from ews-office365-contact-sync.
Hi Graham,
first, thanks for providing your work and your efforts!
I do have the same issue, that login to EWS via ModernAuth is failing.
Yes, I have read redme and unblocked the DLLs and exported the credentials of the service account to a xml.
the svc has got ApplicationImpersonation in Exchange.
I ran:
.\EWSContactSync.ps1 -FolderName 'testsync' -LogPath 'C:\temp\EWS-Office365-Contact-Sync' -MailboxList '[email protected]' -ClientID 'my-Azure-EWS-App-ID' -ModernAuth -ExcludeContactsWithoutPhoneNumber -ExcludeSharedMailboxContacts -CredentialPath "C:\temp\svc-acc.xml"
The first error I got was:
Failed to Sync-ContactList for [email protected] No constructor found. No suitable constructor can be found for the Microsoft.Exchange.WebServices.Data.OAuthCredentials type.
As I said, DLLs are unblocked.
I did some research and found this line in Connect-EXCExchange.ps1:
104: $service.Credentials = New-Object Microsoft.Exchange.WebServices.Data.OAuthCredentials($token.AccessToken)
I changed it to:
104: $service.Credentials = [Microsoft.Exchange.WebServices.Data.OAuthCredentials]$token.AccessToken
It was just a try, as I found this way in another script.
Then the error turned into:
ERROR Failed to Sync-ContactList for [email protected] Exception when calling "AutodiscoverUrl" with 2 argument(s): "Credentials are required to make a service request."
So this didn't work out.
I hope this helps in some way, and I hope you have a suggestions for me, what I can still try..?
Btw., you are checking for EWS dll files this way:
$EWSDLL = (($(Get-ItemProperty -ErrorAction SilentlyContinue -Path Registry::$(Get-ChildItem -ErrorAction SilentlyContinue -Path 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Exchange\Web Services'|Sort-Object Name -Descending| Select-Object -First 1 -ExpandProperty Name)).'Install Directory') + "Microsoft.Exchange.WebServices.dll")
This doesn't return a path, if you have installed the EWS API via "Install-Package Exchange.WebServices.Managed.Api -Version 2.2.1.2".
This way it does:
Just for your information and for a future version. :)
Cheers, Csarly
from ews-office365-contact-sync.
@Csarly Can you try to bypass MFA via trusting the IP of the server you're running the script on, per the guide below? Let me know.
from ews-office365-contact-sync.
Hi @grahamr975 ,
I was trying to use the script with cloud only users and mailboxes.
The admin account with ApplicationImpersonation permission in Exchange is not activated for MFA.
I was running the script from my notebook and desktop pc.
Was it intended to run on a on-premises member server?
Thanks, regards, Csarly
from ews-office365-contact-sync.
Hi @grahamr975 ,
I just discovered it was a layer8 issue ( me ;) ).
In the azure application, in the authentication screen,
Advanced settings -> Allow public client flows -> Enable the following mobile and desktop flows -> needs to be YES !
This wasn't mentioned here:
https://www.m365tech.nl/2020/08/unattended-powershell-scripts-using-modern-authentication-with-exchange-online/
Thanks Ryan!
from ews-office365-contact-sync.
Hi @grahamr975 , I just discovered it was a layer8 issue ( me ;) ). In the azure application, in the authentication screen, Advanced settings -> Allow public client flows -> Enable the following mobile and desktop flows -> needs to be YES !
This wasn't mentioned here: https://www.m365tech.nl/2020/08/unattended-powershell-scripts-using-modern-authentication-with-exchange-online/
Thanks Ryan!
Can you maybe write an little manual how to get it work with api connection?
For now its working for me onprem. But i want to deactivade basic auth. So want to use also the api connection.
How did you write your ps1 script can you share it?
from ews-office365-contact-sync.
hi @nldenic ,
I'm new to GitHub, I am trying to find my way around to provide you with my version...
Thanks for your patience.
from ews-office365-contact-sync.
Hello all,
I just wrote up a guide on how to apply certificate-based authentication to the script, which should resolve this error. See commit 9fcfe1f.
from ews-office365-contact-sync.
Related Issues (20)
- Exclude Specific Users from receiving the GAL sync HOT 1
- Sync Pager HOT 3
- FATAL Failed to fetch Global Address List Contacts from Office 365 Directory Expired or Invalid pagination request. Default Expiry time is 00:30:00 HOT 1
- Failed to fetch Global Address List Contacts from Office 365 Directory - Assembly "System.Net.Http, Version=4.2.0.0 HOT 1
- FolderName = Subfolder of default contacts HOT 2
- Requesting Support for EWS-Office365-Contact-Sync Script HOT 2
- Only contacts with MobilePhone HOT 1
- Better details in docs HOT 1
- Howto specify more than one mailbox to sync from command line ? HOT 5
- Issue adding Fax and Pager fields to the contacts HOT 1
- EWSContactSync.ps1 : Cannot convert the "System.Management HOT 2
- Failed verify that Directory Contacts exists HOT 2
- Could not load file or assembly 'System.Net.Http, Version=4.2.0.0 HOT 4
- Scripts Exceptions in Catch and Get-GALContacts HOT 2
- Sync contacts to the default folder name. HOT 1
- Apply the script only user mailboxes HOT 3
- Identifying errors in the log HOT 1
- Cannot find an appropriate constructor for type Microsoft.Exchange.WebServices.Data.OAuthCredentials HOT 5
- Duplicate Contacts in Folder HOT 1
- Running script in Azure Automation Account HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ews-office365-contact-sync.