【发布时间】:2020-08-17 13:44:27
【问题描述】:
在 VSTO 加载项中,我试图检索连接到 Outlook 的用户的电子邮件地址。出于安全原因,我想确保用户在使用电子邮件地址之前已通过 Exchange 服务器的身份验证。在域内或从外部使用 Outlook Anywhere 或类似的身份验证机制时,身份验证可以是直接的。 到目前为止,我有以下代码:
string authUserEmail = "";
string notAuthUserEmail = "";
AddressEntry currentUserAddressEntry = Application.Session.CurrentUser.AddressEntry;
if (currentUserAddressEntry.Type.Contains("Exchange"))
{
ExchangeUser currentExUser = currentUserAddressEntry.GetExchangeUser();
if(currentExUser != null)
authUserEmail = currentExUser.PrimarySmtpAddress;
}
if (authUserEmail == "")
{
string PR_SMTP_ADDRESS = @"http://schemas.microsoft.com/mapi/proptag/0x39FE001E";
notAuthUserEmail = currentUserAddressEntry.PropertyAccessor.GetProperty(PR_SMTP_ADDRESS) as string;
}
我的问题是:
- 我可以依靠 GetExchangeUser() 函数来检索 Exchange 身份验证用户的详细信息吗?我阅读了here 的帖子,表明这可能是一个问题。
- 是否有更好的方法来检查用户是否通过了交换环境的身份验证? ExchangeConnectionMode 属性会更好吗?
- 如果我依赖 PropertyAccessor 属性,防止有人伪造其他人的电子邮件地址有多安全?
参考资料:
【问题讨论】:
标签: c# vsto exchange-server outlook-addin office-addins