无法找到自动发现服务

发布于 2024-12-11 08:39:10 字数 671 浏览 0 评论 0原文

我有使用 Exchange Web 服务(EWS 1.1 API)发送电子邮件的代码。如果我使用硬编码的参数值,也不例外,例如:

service.AutodiscoverUrl("[email protected]",
    delegate
    {
    return true;
    });

但是如果我尝试使用变量,那么我在发现 URL 时会收到错误,“无法找到自动发现服务”。

string userName = "[email protected]";
service.AutodiscoverUrl(userName,
    delegate
    {
    return true;
    });

有没有办法通过 autodiscoverurl 方法使用变量?我做错了什么?

桑杰

I have code to send email using Exchange Web Services (EWS 1.1 API). There is no exception if I use the hardcoded parameter values, like:

service.AutodiscoverUrl("[email protected]",
    delegate
    {
    return true;
    });

But If I try to use a variable then I am getting error while discovering URL, "The Autodiscover service couldn't be located".

string userName = "[email protected]";
service.AutodiscoverUrl(userName,
    delegate
    {
    return true;
    });

Is there any way to use variables with autodiscoverurl method? What am I doing wrong?

Sanjay

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

究竟谁懂我的在乎 2024-12-18 08:39:10

这不太可能是导致问题的原因。通常,如果自动发现失败,是因为凭据无效或网络连接问题。

在 ExchangeService 实例上启用跟踪(MSDN 文章) 看看发生了什么。

It's very unlikely that this is causing the problem. Typically, if AutoDiscover fails, it's because of invalid credentials or network connectivity issues.

Enable tracing on the ExchangeService instance (MSDN article) to see what is going on.

看轻我的陪伴 2024-12-18 08:39:10

我意识到这篇文章已经有几年了,但我只是为了文档的目的提供一个额外的解决方案。

造成此行为的另一个可能原因是,当 EWS 服务器仅支持 TLS 1.0 时,客户端尝试强制使用 TLS 1.2 连接。我正打算放弃对这种行为的调查——一个 EWS 应用程序在一个盒子上运行,而同一个应用程序在另一个盒子上失败(转到同一个邮箱)——问题是一台机器可以协商 TLS 1.0,它可以工作,而另一个只能执行 TLS 1.2,但失败了。在注册表中启用客户端 TLS 1.0 出站连接(HKLM\System\CCS\Services\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Client,DWORD 值“Enabled”设置为 0x1 修复了该问题。无需重新启动必需的。

I realize this post is a few years old, but I'm offering an additional solution simply for the sake of documentation.

Another possible cause of this behavior is the client is attempting to force a TLS 1.2 connection when the EWS server is supporting only TLS 1.0. I was about to surrender investigating this very behavior - an EWS app worked on one box, and the same app failed on a different box (going to the same mailbox) - and the problem was one machine could negotiate TLS 1.0, which worked, while the other could do TLS 1.2 only, which failed. Enabling client TLS 1.0 outbound connections in the registry (HKLM\System\CCS\Services\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Client, DWORD value 'Enabled' set to 0x1 fixed the problem. No reboot required.

违心° 2024-12-18 08:39:10

只是为了添加另一个解决方案 - 由于与上面的 David W 相反的问题,我一直在苦苦挣扎 - 我的交换服务器仅支持 TLS1.2,但我的应用程序(.net 4.5)默认情况下仅支持 1.0。

通过添加:

System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;

到我的应用程序启动代码来修复。我相信从 .net 4.6 开始默认启用此功能

我收到的具体错误是:

<Trace Tag="AutodiscoverConfiguration" Tid="1" Time="2018-10-29 15:32:40Z">
 failed: WebException (The underlying connection was closed: An unexpected error occurred on a send.)
</Trace>
Exception thrown: 'Microsoft.Exchange.WebServices.Data.AutodiscoverLocalException' in Microsoft.Exchange.WebServices.dll

And just to add another solution - I was struggling because of the opposite problem to David W above - my exchange server only supported TLS1.2, but my app (.net 4.5) only supported 1.0 by default.

Fixed by adding:

System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;

to my app startup code. I believe this is enabled by default for .net 4.6 onwards

The specific error I was getting was:

<Trace Tag="AutodiscoverConfiguration" Tid="1" Time="2018-10-29 15:32:40Z">
 failed: WebException (The underlying connection was closed: An unexpected error occurred on a send.)
</Trace>
Exception thrown: 'Microsoft.Exchange.WebServices.Data.AutodiscoverLocalException' in Microsoft.Exchange.WebServices.dll
┾廆蒐ゝ 2024-12-18 08:39:10

我遇到了同样的问题并解决了添加 .ToString():

$Credential = Get-Credential
$Service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService
$Service.Credentials = New-Object System.Net.NetworkCredential($Credential.UserName.ToString(),$Credential.GetNetworkCredential().password.ToString())
$Service.AutodiscoverUrl($Credential.UserName.ToString(), {$True})

I had the same issue and solved adding .ToString():

$Credential = Get-Credential
$Service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService
$Service.Credentials = New-Object System.Net.NetworkCredential($Credential.UserName.ToString(),$Credential.GetNetworkCredential().password.ToString())
$Service.AutodiscoverUrl($Credential.UserName.ToString(), {$True})
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文