如何获得EWS中已登录用户的显示名? [英] How do I get the displayname of the logged in user in EWS?

查看:75
本文介绍了如何获得EWS中已登录用户的显示名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Exchange自动发现将通过UserSettingName.UserDisplayName属性为我提供用户的显示名称.

Exchange Autodiscovery will give me the user's Display Name via the UserSettingName.UserDisplayName property.

但是,在自动发现失败并且需要手动完成连接的情况下,我不知道如何获取DisplayName.

However, in cases where autodiscovery fails and connection needs to be done manually I can't figure out how to get the DisplayName.

我尝试了这个,但是我只是得到了用户的电子邮件地址:

I tried this, but I just get the users' email address:

 _service = new ExchangeService();
 _service.Credentials = new System.Net.NetworkCredential(exchangeSettings.EmailAddress, exchangeSettings.Password);
 _service.Url = new Uri(exchangeSettings.ExternalEwsUrl);

 NameResolutionCollection resolvedNames = _service.ResolveName(exchangeSettings.EmailAddress);
 exchangeSettings.UserDisplayName = resolvedNames.First().Mailbox.Name;

谢谢

推荐答案

如果要使用ResolveName并且想要displayName,则应使用重载来指定操作应返回AD联系人信息.然后,您可以只使用DisplayName属性.

If you are going to use ResolveName and you want the displayName then you should use the overload to specify that the operation should return the AD contact information. Then you can just use the DisplayName property.

NameResolutionCollection ncCol = 
 service.ResolveName("user@domain.com",ResolveNameSearchLocation.DirectoryOnly,true);

Console.WriteLine(ncCol[0].Contact.DisplayName);

这篇关于如何获得EWS中已登录用户的显示名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆