gpt4 book ai didi

c# - 服务帐户 : Autodiscover service couldn't be located 中的 Exchange 模拟

转载 作者:行者123 更新时间:2023-11-30 15:31:55 25 4
gpt4 key购买 nike

通过 ews 发送一封简单的电子邮件按预期工作 - 从我的帐户到我的帐户:

ExchangeService ews = new ExchangeService(ExchangeVersion.Exchange2010);
ews.AutodiscoverUrl("myname@mydomain.com");
EmailMessage email = new EmailMessage(ews);
email.ToRecipients.Add("myname@mydomain.com");
email.Subject = "HelloWorld";
email.Body = new MessageBody("This is the first email I've sent by using the EWS Managed API");
email.Send();

只是尝试模拟,它也按预期工作 - 在最后一行,它返回我不允许模拟的错误:

ExchangeService ews = new ExchangeService(ExchangeVersion.Exchange2010);
ews.AutodiscoverUrl("myname@mydomain.com");
ews.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, "testuser@mydomain.com");
EmailMessage email = new EmailMessage(ews);
email.ToRecipients.Add("myname@mydomain.com");
email.Subject = "HelloWorld";
email.Body = new MessageBody("This is the first email I've sent by using the EWS Managed API");
email.Send();

现在我尝试使用我的应用程序服务帐户登录:

ExchangeService ews = new ExchangeService(ExchangeVersion.Exchange2010);
ews.Credentials = new NetworkCredential("service", "1234", "mydomain.com");
//ews.Credentials = new WebCredentials("service", "1234");
ews.AutodiscoverUrl("myname@mydomain.com");
//ews.AutodiscoverUrl("service@mydomain.com");
ews.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, "testuser@mydomain.com");
EmailMessage email = new EmailMessage(ews);
email.ToRecipients.Add("myname@mydomain.com");
email.Subject = "HelloWorld";
email.Body = new MessageBody("This is the first email I've sent by using the EWS Managed API");
email.Send();

但这里它在自动发现行中抛出错误:“AutodiscoverLocalException:无法找到自动发现服务。”

在AD和Exchange中设置了服务帐号,密码和smtp地址正确。

为什么它不起作用?如何检查导致该错误的原因?

最佳答案

我解决了问题,猜猜是什么问题:是用户帐户。

EWS 使用给定的凭据对自身进行身份验证,以访问 Autodiscover 服务

http://mydomain/AutoDiscover/AutoDiscover.xml

凭据是正确的,但似乎对于设置为“用户必须在首次登录时更改密码”的帐户,对自动发现服务的访问被拒绝。我在 AD 中更改了该设置,现在可以使用了。

关于c# - 服务帐户 : Autodiscover service couldn't be located 中的 Exchange 模拟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19909442/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com