我有一個ASP .Net Application
託管在Windows Server 2016
IIS 10
。 Impersonation
和Windows Authentication
已啓用。允許模擬用戶通過EWS託管API 2.0登錄到Exchange服務器
我希望登錄Active Directory用戶執行一些與他們自己的郵箱相關的操作,而無需任何額外的登錄(我的意思是不輸入用戶名/密碼)。
是否有可能以及對Exchange Server
,Active Directory
用戶和託管應用程序的服務器進行了哪些配置更改?
還有就是我如何使用EWS Managed API
:
using (var context = WindowsIdentity.GetCurrent().Impersonate())
{
string mailbox = "[email protected]"
ExchangeService service = new ExchangeService();
service.AutodiscoverUrl(mailbox);
service.Url = new Uri(serverAddress);
service.UseDefaultCredentials = true;
service.Credentials = CredentialCache.DefaultNetworkCredentials;
var rootFolder = Folder.Bind(service, new FolderId(WellKnownFolderName.MsgFolderRoot, mailbox));
}
在這種情況下,與AutodiscoverUrl
我有一個錯誤:The Autodiscover service couldn't be located.
當我儘量避免AutodiscoverUrl
,像這樣:
using (var context = WindowsIdentity.GetCurrent().Impersonate())
{
string serverAddress = "https://domain.com/EWS/Exchange.asmx";
string mailbox = "[email protected]"
ExchangeService service = new ExchangeService();
service.Url = new Uri(serverAddress);
service.UseDefaultCredentials = true;
service.Credentials = CredentialCache.DefaultNetworkCredentials;
var rootFolder = Folder.Bind(service, new FolderId(WellKnownFolderName.MsgFolderRoot, mailbox));
}
我也滿足了錯誤:The request failed. The remote server returned an error: (401) Unauthorized.
請問您能否推薦如何配置這些服務器讓它們相互通信?
在此示例中,使用憑證授權用於訪問服務。 (在default.aspx.cs)。不幸的是,它不能解決我遇到的問題 –
您需要閱讀帖子(不只是看例子),它涵蓋了憑證和模擬,重要的是允許委派和使用Kerberos。要理解的是在客戶端和IIS之間必須使用kerberos(而不是IIS到EWS),那麼IIS將能夠委託憑據(對其進行設置)並使用它們建立與EWS的連接(如果配置正確) –