使用手动设置的凭证时,EWS自动发现停止工作 [英] When using manually set credentials, EWS auto discover stops working

查看:129
本文介绍了使用手动设置的凭证时,EWS自动发现停止工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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("user@example.com", redirect => true);

这没有:

service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.UseDefaultCredentials = false;
service.Credentials = new NetworkCredential("user", "pass", "EXAMPLE_DOMAIN");
service.AutodiscoverUrl("user@example.com", redirect => true);

给定的网络凭据应与默认凭据完全相同,但是在启用跟踪时,在第二种情况下,我会收到响应"401未经授权",因此它的作用就好像是相同的一样.

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.

我想念什么?

推荐答案

好吧,看来您需要使用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.

这篇关于使用手动设置的凭证时,EWS自动发现停止工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆