具有基本身份验证的Exchange Online和EWS停止工作

问题描述 投票:0回答:1

我想使用具有基本身份验证的EWS托管API连接到Exchange Online。

但是在我的应用程序中,当使用基本身份验证时,EWS AutodiscoverService无法从Exchange Online检索邮箱设置(GetUserSettings),但是oAuth可以正常工作。

我收到一条带有以下消息的Microsoft.Exchange.WebServices.Data.ServiceRequestException连接尝试失败,因为连接的用户在一段时间后未正确响应,或者建立的连接失败,因为连接的主机未能响应40.101.50.162:444

我使用基本身份验证已经有好几年了,几天前它刚刚停止工作。在Exchange Online和EWS上不再可以使用基本身份验证吗?

代码示例

var ads = new AutodiscoverService
             {
                 RedirectionUrlValidationCallback = url => true,
                 EnableScpLookup = false
             };
ads.Credentials = new NetworkCredential( svcUsr, svcPwd ); // using these will throw an exception
ads.Credentials = new OAuthCredentials( token.AccessToken ); // these works
var res = ads.GetUserSettings( mailBox, UserSettingName.GroupingInformation );

例外

Microsoft.Exchange.WebServices.Data.ServiceRequestException: The request failed. Unable to connect to the remote server ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 40.101.28.194:444
       at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
       at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
       --- End of inner exception stack trace ---
       at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
       at System.Net.HttpWebRequest.GetRequestStream()
       at Microsoft.Exchange.WebServices.Data.EwsHttpWebRequest.Microsoft.Exchange.WebServices.Data.IEwsHttpWebRequest.GetRequestStream()
       at Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverRequest.InternalExecute()
       --- End of inner exception stack trace ---
       at Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverRequest.InternalExecute()
       at Microsoft.Exchange.WebServices.Autodiscover.GetUserSettingsRequest.Execute()
       at Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.InternalGetUserSettings(List`1 smtpAddresses, List`1 settings, Nullable`1 requestedVersion, Uri& autodiscoverUrl)
       at Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.GetSettings[TGetSettingsResponseCollection,TSettingName](List`1 identities, List`1 settings, Nullable`1 requestedVersion, GetSettingsMethod`2 getSettingsMethod, Func`1 getDomainMethod)
       at Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.GetUserSettings(List`1 smtpAddresses, List`1 settings)
       at Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.InternalGetSoapUserSettings(String smtpAddress, List`1 requestedSettings)
       at Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.GetUserSettings(String userSmtpAddress, UserSettingName[] userSettingNames)
       at EWSAutoDiscovery.Program.Main(String[] args) in C:\Program.cs:line 57

经过测试和验证的[更新1]

  1. 我已经验证了某些EWS操作仍然可以使用基本身份验证,例如SyncFolderItems
  2. 我已经确认服务帐户用户或EXO常规配置都具有身份验证策略。
  3. 我创建了一个在所有协议上都启用BasicAuth的身份验证策略,并将其分配给EXO组织配置DefaultAuthenticationPolicy参数。
  4. 我已将身份验证策略分配给服务帐户以及目标用户。
  5. 我已删除并在服务帐户上重新应用了ApplicationImpersonation角色。
c# office365 exchangewebservices
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.