SharePoint – Change User Profile Picture for Single

In this post I will show how to change User Profile Picture for Single .

Using Console Application in Visual Studio .Net, I deploy and change picture based on User ID (as custom column in CA from AD):

For Single User:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Office.Server;
using Microsoft.Office.Server.UserProfiles;
using Microsoft.SharePoint;

namespace UserProfilePicURL_SUser
class Program
static void Main(string[] args)
using (SPSite site = new SPSite(“SiteURL”))
SPServiceContext context = SPServiceContext.GetContext(site);
UserProfileManager myUserProfileManager = new UserProfileManager(context);
UserProfile aUser = myUserProfileManager.GetUserProfile(“Domain\\UserAccount”);

string origUrl = (string)aUser[PropertyConstants.PictureUrl].Value;
string displayName = (string)aUser[PropertyConstants.AccountName].Value;
string hUID = (string)aUser[“UserID”].Value;

string newUrl2 = “PictureURL/UserID.jpg”;
aUser[PropertyConstants.PictureUrl].Value = newUrl2.ToString();
Console.WriteLine(“Account Name: ” + displayName.ToString());
Console.WriteLine(“Image URL: ” + newUrl2.ToString());
Console.WriteLine(“User ID Account: ” + hUID.ToString());

catch (System.Exception ex)

Happy SharePoint


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s