How do you get the user profile picture from an SPUser profile?
2 Answers
You can look at the User Information List, to grab the Picture column contents. It's a hidden field, so you might have to write a console app to get the columns, or find a reference somewhere online.
Tobias Zimmergren did a blog post on getting user data from the User Information List from an SPUser object: http://www.zimmergren.net/archive/2008/06/25/sharepoints-hidden-user-list-user-information-list.aspx
You can do something like this:
public string GetUserPicture(SPSite site)
{
string userAccount = "domain\\account";
ServerContext ctx = ServerContext.GetContext(site);
UserProfileManager upm = new UserProfileManager(ctx);
UserProfile up = upm.GetUserProfile(userAccount);
return up["PictureUrl"].Value;
}
-
1tarjeieo : when user do not have change his profile picture that time it gives error. can we have some check on pictureUrl? Jul 11, 2014 at 13:45