簡體   English   中英

設置模擬上下文后從服務器通過Exchange Web Services進行身份驗證

[英]Authenticating with Exchange Web Services from server after setting up impersonation context

我要在本地網絡上使用的應用程序具有以下設置:

Silverlight Client App -> Web Server (data objects etc) | -> Exchange
                                                        | -> SQL Database

一切正常,我可以從數據庫中獲取數據,等等(可能值得注意的是,我正在使用SQL auth for SQL而不是Windows auth),但是當我嘗試通過Exchange Web Services從交換中獲取當前用戶的日歷項時它給了我一個401 unauthorised錯誤。

所有這些都在我的本地開發服務器(在我的機器上)上運行,該服務器在使用默認ApplicationPoolIdentity的經典ASP.NET 4應用程序池下運行。 我不是通過SSL進入,而是通過端口81進入

我可以連接以獲得自己的日歷條目, 但是對於其他用戶,我會收到錯誤消息

如果我在沒有模擬代碼的情況下嘗試使用該工具,則Connection did not succeed. Please try again later 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為KerberosImpersonationLevelImpersonate 據我所知,這應該可以正常工作,但看來我的Web服務器不想通過交換成功進行身份驗證。

我在裝置或交換中缺少什么嗎?

最終這最終可以工作-最終成為一些交換設置,並使用當前線程主體而不是系統主體

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM