c# - ews 找不到领域的 KDC

标签 c# asp.net-core raspberry-pi exchangewebservices

我正在尝试使用 .net 核心获取以下 c# 代码以在 raspberry pi 上运行,该代码在 Windows 上运行良好并且完全按照我的要求执行。但是在 pi 上,它给了我一个涉及 kerberos 的奇怪异常。我过去曾用这个 pi 运行其他 .net 核心程序。

我的代码是:

using System;
using Microsoft.Exchange.WebServices.Data;

namespace Test
{
class Program
{
    static void Main(string[] args)

    {
            // Create the binding to ews
            ExchangeService service = new ExchangeService();
            // Set the credentials for the user
            service.Credentials = new WebCredentials("user@email.com", "password");
            // Set the URL
            service.Url = new Uri("https://email.com/ews/Exchange.asmx");
            // Create a bew email
            EmailMessage email = new EmailMessage(service);
            // Set the recipiant to an email
            email.ToRecipients.Add("user@email.com");
            // Set the subject
            email.Subject = "HelloWorld";
            // Set the body
            email.Body = new MessageBody("This is the first email I've sent by using the EWS Managed API.");
            email.Send();
    }
}
}

但是,当我使用 dotnet core 将其发布到 linux-arm 然后在 pi 上运行它时,出现以下异常

Unhandled Exception: System.ComponentModel.Win32Exception: GSSAPI operation failed with error - An invalid status code was supplied (Cannot find KDC for realm "email.com").
      at System.Net.HttpWebRequest.GetResponse()
      at 
 Microsoft.Exchange.WebServices.Data.EwsHttpWebRequest.Microsoft.Exchange.WebServices.Data.IEwsHttpWebRequest.GetResponse()
  at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.GetEwsHttpWebResponse(IEwsHttpWebRequest request)
  at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ValidateAndEmitRequest(IEwsHttpWebRequest& request)
  at Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.Execute()
  at Microsoft.Exchange.WebServices.Data.ExchangeService.InternalCreateItems(IEnumerable`1 items, FolderId parentFolderId, Nullable`1 messageDisposition, Nullable`1 sendInvitationsMode, ServiceErrorHandling errorHandling)
  at Microsoft.Exchange.WebServices.Data.Item.InternalCreate(FolderId parentFolderId, Nullable`1 messageDisposition, Nullable`1 sendInvitationsMode)
  at Microsoft.Exchange.WebServices.Data.EmailMessage.InternalSend(FolderId parentFolderId, MessageDisposition messageDisposition)
  at Microsoft.Exchange.WebServices.Data.EmailMessage.Send()
  at Test.Program.Main(String[] args) in V:\visual studio stuff\Test\Test\Test\Program.cs:line 23

任何帮助都会很棒

最佳答案

如果你需要 GSSApi,你应该安装 gss-ntlmssp,它是 Kerberos 插件的包。如果仍未解决,请查看此 GitHb Issue这似乎是你的。

关于c# - ews 找不到领域的 KDC,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51399990/

相关文章:

c# - API设计中如何避免 "too many parameters"问题?

c# - 使用带有 WCF SOAP 的 XmlSerializer 添加根 xmlns

c# - 如何使用新方法动态扩展 C# 类

c# - Azure Functions 中的孤立异步任务

asp.net-core - Google Drive Api 错误 403 无法使用服务帐户添加父级

c# - 通过 Web api 将大文件(> 1 GB)上传到 Azure Blob 存储

c# - Xamarin不包括构建中的资源文件夹

python - 在打开的树莓派上运行 python 脚本

c++ - 将 C 程序的值发布到网页

python - 在 Ubuntu 服务器上使用 python 获取写入 USB 闪存驱动器的必要权限