C#代码不用域名访问交换服务器,可以吗?

发布于 2024-11-19 08:42:52 字数 886 浏览 2 评论 0原文

我正在开发一个 Web 应用程序来访问 Exchange Server 2010 以从服务器获取电子邮件。问题是,我们没有该服务器的域名。我所知道的是它的IP地址。是否可以使用 Exchange Web Service 访问服务器?这是我的代码:

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010); service.Credentials=new NetworkCredential("StevenZack","123456","208.243.49.20"); //service.AutodiscoverUrl("[电子邮件受保护]"); service.Url = new Uri("https://208.243.49.20/EWS/Exchange.asmx"); FindItemsResults findResults = service.FindItems( WellKnownFolderName.Inbox, 新的 ItemView(10));

    foreach (Item item in findResults.Items)
    {
        div_email.InnerHtml = item.Subject + "<br />";
    }

出现错误“根据验证程序,远程证书无效”

如何处理这种情况?有什么想法吗?谢谢您的宝贵时间!

I'm working on a web application to access exchange server 2010 to get emails from the server. The question is, we don't have domain name for this server. What I know is it's IP address. Is that possible to use Exchange Web Service to access the server? This is my code:

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010);
service.Credentials=new NetworkCredential("StevenZack","123456","208.243.49.20");
//service.AutodiscoverUrl("[email protected]");
service.Url = new Uri("https://208.243.49.20/EWS/Exchange.asmx");
FindItemsResults findResults = service.FindItems(
WellKnownFolderName.Inbox,
new ItemView(10));

    foreach (Item item in findResults.Items)
    {
        div_email.InnerHtml = item.Subject + "<br />";
    }

It comes out with an error of "The remote certificate is invalid according to the validation procedure"

How to deal with this situation? Any idea? Thank you for your time!

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

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

发布评论

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

评论(1

ペ泪落弦音 2024-11-26 08:42:52

通过设置 ServicePointManager.ServerCertificateValidationCallback 委托可以避免 SSL 警告(请参阅 http://www.infinitec.de/post/2008/11/26/ExchangeWebServices-WebDAV-and-untrusted-server-certificates.aspx)。

但这可能对你没有帮助。如果指定 208.243.49.20,则您将使用计算机本地帐户而不是域帐户连接到计算机。

您可以使用集成身份验证吗?您可以冒充用户并直接使用他的凭据。这样,用户就不必再次输入其凭据。请注意,如果您的 Web 应用程序与 Exchange 服务器驻留在不同的服务器上,则需要配置 Kerberos。

The SSL warning can be avoiding by setting the ServicePointManager.ServerCertificateValidationCallback delegate (see http://www.infinitec.de/post/2008/11/26/ExchangeWebServices-WebDAV-and-untrusted-server-certificates.aspx).

But this probably won't help you. If you specify 208.243.49.20 you are connecting to the machine using a machine-local account instead of your domain account.

Can you, by any chance, use integrated authentication? You could just impersonate the user and use his credential directly. This way, the user doesn't have to enter his credentials again. Note that you would need to configure Kerberos if your web application resides on a different server as your Exchange server.

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