不要致電AutoDiscoverUrl()
,您可以set the url directly usingexchangeService.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");
。
此外,調用AutoDiscoverUrl()
後,你也可以檢查你的ExchangeService
對象的Url
性能,看它是否解決了一個安全的端點或您(在例如你的配置文件從一個特定的列表)信任的端點。
爲了確保返回的Url安全可靠,您應該驗證返回的證書是否來自您期望它的組織,並且證書是由受信任的權威機構簽署的。這process is explained here。文章中提到的默認實現也接受自簽名證書,您可能不希望在生產代碼中這樣做。例如,您可以將證書固定到特定的指紋。
如果要排除自簽名的證書,所引用的樣本中更改下面的代碼返回false:
// When processing reaches this line, the only errors in the certificate chain are
// untrusted root errors for self-signed certificates. These certificates are valid
// for default Exchange server installations, so return true.
// Or when you know that the certificate is signed by a trusted root authority, return false.
return false;
要回答你的問題,用戶名/密碼是使用NTLM或Kerberos正常安全地發送。在最壞的情況下they can be sent using basic authentication,但是如果你通過SSL連接,只要你正確地驗證SSL證書,就不應該很容易攔截密碼。
**您如何連接到EWS?請告訴我們你的代碼。 – Dai
'ExchangeService svc = new ExchangeService(); svc.Credentials =新的WebCredentials(AuthEmailAddress,AuthEmailPassword); svc.AutodiscoverUrl(AutoDiscoverEmailAddress);' – TheDudeDude