Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

How do you get the user profile picture from an SPUser profile?

share|improve this question
    
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

2 Answers 2

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

share|improve this answer

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;
}
share|improve this answer
    
tarjeieo : 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 at 13:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.