使用手动设置凭据时,EWS 自动发现停止工作

发布于 2025-01-08 01:22:43 字数 948 浏览 4 评论 0原文

我遇到了一个非常奇怪的问题,我确信这只是我忽略的一些愚蠢的事情。使用 EWS 托管 API,我尝试连接到邮箱以读取联系人。最初,我使用默认凭据,在这种情况下自动发现有效。问题是,稍后我们想在服务器上运行它并模拟用户,所以我通过手动指定凭据来更改它。即使使用我自己的凭据,这个问题也被打破了。

例如,这有效:

service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.AutodiscoverUrl("[email protected]", redirect => true);

这没有:

service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.UseDefaultCredentials = false;
service.Credentials = new NetworkCredential("user", "pass", "EXAMPLE_DOMAIN");
service.AutodiscoverUrl("[email protected]", redirect => true);

给定的网络凭据应该与默认凭据完全相同,但是在启用跟踪时,我在第二种情况下得到响应“401 Unauthorized”,因此它不充当如果是一样的话。

我缺少什么?

I am running into a very strange issue and I am convinced it is just something stupid that I am overlooking. Using the EWS managed API, I try to connect to a mailbox to read the contacts. Originally, I used the default credentials, in which case the auto discovery worked. The problem is that later on we want to run this on a server and impersonate a user, so I changed it by manually specifying the credentials. This then broke, even when using my own credentials.

As an example, this worked:

service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.AutodiscoverUrl("[email protected]", redirect => true);

This did not:

service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.UseDefaultCredentials = false;
service.Credentials = new NetworkCredential("user", "pass", "EXAMPLE_DOMAIN");
service.AutodiscoverUrl("[email protected]", redirect => true);

The given network credentials should be exactly the same as the default credentials, but when enabling the tracing, I get the response "401 Unauthorized" in the second case, so it is not acting as if it is the same.

What am I missing?

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

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

发布评论

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

评论(1

分開簡單 2025-01-15 01:22:43

好的,看来您需要使用 WebCredential("user", "pass", "EXAMPLE_DOMAIN")。我不太确定为什么 WebCredentials 有效,但 NetworkCredentials 无效。

Ok, it seems that you need to use WebCredential("user", "pass", "EXAMPLE_DOMAIN"). I am not exactly sure why WebCredentials work but NetworkCredentials does not.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文