In this post, we will discuss how we can get profile picture url from User Information List using SharePoint 2013 server object model. User Information List is a hidden list maintains by SharePoint which contains one entry for every user who accessed the site collection or explicit access has been given to any particular user. This list contains basic information like About me, Picture url, Name, Title, Department etc.
If SharePoint farm is using User Profile Application, then these User Information List fields will not be editable rather it will redirect to My Site Host. If your SharePoint farm is not using User Profile Application, the user can be able to edit the User Information List fields.
Also, you may need to check:
– SharePoint 2013 SPListItem method Update SystemUpdate and UpdateOverwriteVersion
Here in this example, we will try to retrieve the user profile picture url from User Information List using the Server object model.
Below is the full code.
string LoginName = string.Empty;
string SiteUrl = SPContext.Current.Site.Url;
string Username = SPContext.Current.Web.CurrentUser.LoginName;
SPSite Site = new SPSite(SiteUrl);
string pictureUrl = string.Empty;
using (SPWeb Web = Site.OpenWeb())
SPList List = Web.Lists[“User Information List”];
SPQuery Query = new SPQuery();
Query.Query = “<Where><Eq><FieldRef Name = ‘ID’/><Value Type=’Text’>”+Username+”</Value></Eq></Where>”;
ItemCollection = List.GetItems(Query);
if (ItemCollection.Count > 0)
foreach(SPListItem ListItem in ItemCollection)
if(ListItem[“Picture”] != null)
pictureUrl = ListItem[“Picture”].ToString();
Hope this will be helpful.
-: FREE PDF e-Book Download :-
51 JSOM Examples in SharePoint Online
You May Also like the Following SharePoint Online Tutorials: