2012-01-16 70 views
2

我已將Active Directory與我的用戶配置文件服務相關聯,並從AD添加了自定義屬性(employeeNumber)。在完全同步用戶配置文件服務之後,我可以從Central Admin正確讀取所有employeeNumber屬性值,並且管理面板中的用戶配置文件屬性計數爲69。用戶配置文件服務 - 自定義屬性 - 未找到屬性

但是,當我試圖從我的SharePoint應用程序讀取employeeNumber數據時,它拋出異常「找不到屬性」,和用戶檔案管理的物業數量是68

我已經設置我的自定義屬性的隱私設置爲「所有人」,並確定我在代碼中使用了正確的內部自定義屬性名稱。

有什麼建議嗎?

這裏是我的代碼示例:

  SPServiceContext serverContext = SPServiceContext.GetContext(SPContext.Current.Site); 
      UserProfileManager profileManager = new UserProfileManager(serverContext); 
      UserProfile user = profileManager.GetUserProfile(System.Web.HttpContext.Current.User.Identity.Name); 

      int count = profileManager.Properties.Count; // Count = 68 [custom prop is not included] 
      string department = user["Department"].Value.ToString(); // Works fine 
      string employeeNumber = user["employeeNumber"].Value.ToString(); // Property Not Found 
+0

遍歷UserProfile用戶集合並發現所有屬性名稱 – 2012-07-24 07:57:27

回答

1

其中一個原因可能是你已經創建了多個用戶配置文件服務應用程序和Web應用程序使用(你想上面的代碼)服務應用程序實例,而不是您添加自定義屬性的實例。