简体   繁体   English

如何通过当前的Windows用户凭据连接到Exchange Server?

[英]How connect to Exchange Server via current Windows user credentials?

What the problem is? 问题是什么?

We have an Exchange Server 2010 SP2, IIS 7.5 and a console app in VS2013. 我们在VS2013中有一个Exchange Server 2010 SP2,IIS 7.5和一个控制台应用程序。

So we have done the following: 所以我们做了以下事情:

TimeZoneInfo timeZone = TimeZoneInfo.Local;
ExchangeService EWSservice = new ExchangeService(ExchangeVersion.Exchange2010_SP2, timeZone);
//EWSservice.Url = new Uri("our url");
EWSservice.AutodiscoverUrl("my@mail.com", RedirectionUrlValidationCallback);

Both ways to define the url are working. 定义网址的两种方式都有效。 Trying to set credentials: 尝试设置凭据:

EWSservice.Credentials = new WebCredentials("my@mail.com", "mypass"); 

This works too. 这也有效。 But I want to connect by using the current Windows user credentials. 但我想通过使用当前的Windows用户凭据进行连接。 Some code samples that had been used and crashed: 一些已使用和崩溃的代码示例:

  • EWSservice.Credentials = new WebCredentials(CredentialCache.DefaultCredentials);

  • EWSservice.UseDefaultCredentials = true;

  • EWSservice.Credentials = (NetworkCredential)CredentialCache.DefaultCredentials;

All of this has returned a 401 error: Unauthorized 所有这些都返回了401错误:未经授权

Additionally, I have edited the app.config like this - but it doesn't work: 另外,我已经像这样编辑了app.config - 但它不起作用:

<authentication mode="Windows">
    </authentication>
    <identity impersonate="false"/>
    <!--Other stuff-->
</authentication>

Then, I have read about authentication modes and found this: Windows User getting "access denied" from exchange server 然后,我已阅读有关身份验证模式的信息并发现: Windows用户从Exchange服务器获取“访问被拒绝”

The admin has set this delegate option, but the connection is still not working... 管理员已设置此委托选项,但连接仍然无法正常工作...

Now I have added this: 现在我添加了这个:

EWSservice.TraceEnabled = true;

and I get an Exchange response in the console: 我在控制台中收到Exchange响应:

HTTP/1.1 401 Unauthorized
Content-Length: 0
Date: Wed, 20 Apr 2016 07:59:01 GMT
Set-Cookie: exchangecookie=bfab7cdda62a4bf8be5b43689199fcf6; expires=Thu, 20-Apr
-2017 07:59:02 GMT; path=/; HttpOnly
Server: Microsoft-IIS/7.5
WWW-Authenticate: Basic realm="our-domain"
X-Powered-By: ASP.NET

Any ideas? 有任何想法吗?

I don't think your approach is possible but you may want to look at this .... 我不认为你的方法是可行的,但你可能想看看这个....

How to get the current user's Active Directory details in C# 如何在C#中获取当前用户的Active Directory详细信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将当前(Windows)用户的凭据分配给ftpWebRequest - How to assign credentials of current (Windows) user to ftpWebRequest 如何使用客户端Windows凭据连接到Web中的SQL Server数据库 - How to connect to SQL Server database in web using client windows credentials 如何测试Exchange Server -2003凭据 - How to test Exchange Server -2003 credentials 将用户凭证传递给Exchange - Passing User Credentials to Exchange 如何使用C#通过RPC over HTTP连接到Exchange Server - How to use C# to connect to Exchange Server via RPC Over HTTPs 从Windows身份验证应用程序中的当前用户获取网络凭据 - Obtain Network Credentials from Current User in Windows Authentication Application 是否可以使用当前的Windows用户凭据调用ac#WebService? - Is it possible to call a c# WebService with current windows user credentials? 如何使用EWS托管API验证Exchange凭据和验证Exchange服务器通信? - How to validate Exchange credentials and verify Exchange server communication using EWS managed API? 远程连接到SQL Server-可信连接,Windows凭据 - Remote connect to SQL server - trusted connection, windows credentials 如何触发 Windows 以获取用户凭据提示? - How to trigger Windows for user credentials prompt?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM