Onur Yavuz
Onur Yavuz

Reputation: 101

User Profile Service - Custom Property - Property Not Found

I've attached my Active Directory with my User Profile Service, and added a custom property (employeeNumber) from AD. After i fullly sync the user profile service, i can read all employeeNumber property values correctly from Central Admin, and also user profile property count is 69 in admin panel.

But, when i try to read the employeeNumber data from my sharepoint application, it throws the exception "Property Not Found", and the property count of the user profile manager is 68.

I've already set my custom property's privacy setting to "Everyone" and pretty sure that i'm using the correct internal custom property name in my code.

Any suggestions?

Here is my code sample:

            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

Upvotes: 2

Views: 1159

Answers (1)

Prateek Bansal
Prateek Bansal

Reputation: 31

One of the reasons might be that you have created more than one user profile service applications and the web application(you are trying the above code for) is using a service application instance other than the one you added the custom property in.

Upvotes: 1

Related Questions