Correct Way of Getting User Profile Property Value
using (SPSite site = new SPSite(url))
{
UserProfileManager userProfileManager = new UserProfileManager(SPServiceContext.GetContext(site));
UserProfile userProfile = userProfileManager.GetUserProfile(accountName);
if (userProfile["<PropertyInternalName>"] != null)
{
if (userProfile["<PropertyInternalName>"].Value != null)
{
string propertyValue = userProfile["<PropertyInternalName>"].Value.ToString();
}
}
}
No comments:
Post a Comment