C# 在sharepoint 2010中从MySite获取Office价值

C# 在sharepoint 2010中从MySite获取Office价值,c#,sharepoint-2010,C#,Sharepoint 2010,我正在尝试使用以下代码从Sharepoint 2010网站中用户的Mysite中获取值“Office”: SPSite site = SPContext.Current.Site; SPServiceContext serviceContext = SPServiceContext.GetContext(oSite); UserProfileManager manager = new UserProfileManager(serviceContext);

我正在尝试使用以下代码从Sharepoint 2010网站中用户的Mysite中获取值“Office”:

SPSite site = SPContext.Current.Site;

      SPServiceContext serviceContext = SPServiceContext.GetContext(oSite);

        UserProfileManager manager = new UserProfileManager(serviceContext);

          UserProfile profile = manager.GetUserProfile(oUser.ToString());
                                        var Office = profile[PropertyConstants.Office].Value;
                                        var faxnum= profile[PropertyConstants.fax].Value;
尽管数字和许多其他值可以正常工作,但Office始终返回Null。我相信这是因为它是托管元数据,但我不确定这是问题所在

我也尝试过相同代码的不同变体,但没有乐趣

有什么想法吗

var Office = profile[PropertyConstants.Office] != null ? profile[PropertyConstants.Office].Value : String.Empty; 

首先尝试处理null

是的,我发现物业办公室不能由用户更改,但它可能会被更新,可能是从广告?