我正在尝试使用 .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/