Enable to SharePoint User Information List
- protected void EnableUSIList(object sender, EventArgs e)
- {
- try
- {
- string strFields = "";
-
- SPSite Site = SPContext.Current.Site;
- Context.Response.Output.Write(Site + "<br/>");
- using (SPWeb Web = Site.OpenWeb())
- {
- Web.AllowUnsafeUpdates = true;
- SPList List = Web.Lists["User Information List"];
- Context.Response.Output.Write(List.ToString() + "<br/>");
- List.Hidden = false;
- List.Update();
- Web.AllowUnsafeUpdates = false;
- Context.Response.Output.Write(List.Hidden.ToString() + "<br/>");
-
- }
- }
- catch (Exception ex)
- {
- Context.Response.Output.Write("Errors: " + ex.Message.ToString());
- }
-
- }
Get Programmatically Profile Picture Url from User Information List of Sharepoint
- 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());
-
- }
No comments:
Post a Comment