【发布时间】:2012-09-12 12:01:41
【问题描述】:
我为要在本地网络上使用的应用程序进行了以下设置:
Silverlight Client App -> Web Server (data objects etc) | -> Exchange
| -> SQL Database
其他一切正常,我可以从数据库等获取数据(可能值得注意的是,我使用的是 SQL 身份验证而不是 Windows 身份验证),但是当我尝试从交换中获取当前用户的日历条目时使用Exchange Web Services 它给了我一个401 unauthorised 错误。
这一切都在我的本地开发服务器(在我的机器上)上运行,该服务器在使用默认 ApplicationPoolIdentity 的经典 ASP.NET 4 应用程序池下运行。我不是通过 SSL 进入的,只是通过端口 81
我可以连接以获取我自己的个日历条目,但对于其他用户我收到错误
如果我在没有模拟代码的情况下尝试它,我会收到 Connection did not succeed. Please try again later 错误,因为我假设 EWS 将使用没有域登录的 ApplicationPoolIdentity。
我已使用以下代码进行模拟(暂时忽略任何可能未处理的异常/安全漏洞,我只想让它工作!):
var impersonationContext = ((System.Security.Principal.WindowsIdentity)System.Threading.Thread.CurrentPrincipal.Identity).Impersonate();
// Use default credentials
service.UseDefaultCredentials = true;
// Get the target folder ID using the email address
var folder = new FolderId(WellKnownFolderName.Calendar, new Mailbox(emailAddress));
// Get the appointments
var response = service.FindAppointments(folder, view);
impersonationContext.Undo();
// Return list of appointment entities
return response.Items;
查看System.Security.Principal.GetCurrent()可以看出,调用Impersonate方法后,用户更改为我要模拟的用户的身份。 AuthenticationType 是 Kerberos,ImpersonationLevel 是 Impersonate。据我所知,这应该可以工作,但看起来我的网络服务器不想通过交换成功进行身份验证。
我是否在设置或交换中遗漏了什么?
【问题讨论】:
-
AFAIK 因为“服务器跃点”,这仅在您为服务器启用 Kerberos 委派时才有效。
标签: c# asp.net kerberos exchangewebservices