I am fetching the user data from the user profile service. I have created a custom property for EmpId. When I try to access its value NullReferenceException is thrown.
How can I access the value from the custom property?
Please guide.
I am fetching the user data from the user profile service. I have created a custom property for EmpId. When I try to access its value NullReferenceException is thrown.
How can I access the value from the custom property?
Please guide.
Example of usage
SPServiceContext serviceContext = SPServiceContext.GetContext(ctx.Site);
// Then load the UserProfileManager
UserProfileManager mngr = new UserProfileManager(serviceContext);
// Get the user’s profile
UserProfile currentProfile = mngr.GetUserProfile(true);
// If the user has a profile, get the SocialTagManager
if (currentProfile != null)
{
//Do your stuff
}
Also have a look here (NOT best practice but it'll get you started) http://msdn.microsoft.com/en-us/library/ms544366.aspx and here for custom properties http://msdn.microsoft.com/en-us/library/ms519896.aspx
Do remember to run a FULL Syncro or otherwise you custom property might not be having values in it already!
Hope it helps, C:\Marius