2014-10-07 16 views
1

我需要知道我怎么可以从Active Directory检索ZipCode。目前,我可以得到UserDepartment但我不能检索ZipCode如何从SharePoint 2010中的UserProfileManager检索ZipCode?

docs我看不到ZipCode作为一个属性:

这是我在C#代码:

using(SPSite site = new SPSite("Server")) 
{ 
    site.AllowUnsafeUpdates = true; 
    SPServiceContext context = SPServiceContext.GetContext(site); 
    UserProfileManager upm = new UserProfileManager(context); 
    UserProfile profile = upm.GetUserProfile(GetNodeValue("xPath")); 
    String department = profile[PropertyConstants.Department].Value.ToString(); 
    String position = profile[PropertyConstants.Title].Value.ToString(); 
    String zipCode = profile[PropertyConstants.?????].Value.ToString(); 
} 

回答

1

您需要手动在用户配置文件服务应用程序首先映射此。

属性可以在管理中心中添加 - >管理服务应用程序 - >用户配置文件服务应用程序 - >管理用户属性 - >添加用户配置文件属性 - >选择邮编属性。现在

您可以运行同步,每个用户都应该有这个属性映射。然后,您可以访问它就像你正在做的,但与字符串名称您分配:

String zipCode = profile["SPS-ZipCode"].Value.ToString(); 

enter image description here

相关问题