不要致电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