Get Profile Picture Url from User Information List Of Sharepoint

Sagarp
Posted by Sagarp under SharePoint category on | Points: 40 | Views : 6385
try	
{
string LoginName = string.Empty;
string SiteUrl = SPContext.Current.Site.Url;
string Username = SPContext.Current.Web.CurrentUser.LoginName;

SPSite Site = new SPSite(SiteUrl);

string data = 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>";

SPListItemCollection ItemCollection;
ItemCollection = List.GetItems(Query);
if (ItemCollection.Count > 0)
{
foreach(SPListItem ListItem in ItemCollection)
{
if (ListItem["Picture"] != null)
{
data = ListItem["Picture"].ToString();

}
}

}
}
}
catch(Exception ex)
{
Context.Response.Output.Write("Error : " + ex.Message.ToString());
}

Comments or Responses

Login to post response