How do you get the user profile picture from an SPUser profile?
-
do you need some kind of permissions to get the pictures of other users than yourself? I only get my own picture. – Gene Vangampelaere Feb 17 '12 at 13:09
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? – love thakker Jul 11 '14 at 13:45