Posts

Showing posts from December, 2017

Adding Items to List in By using Admin account or Any other domain account

Dear All,  Some time you want to add the item in the list which user doesn't have a permission, the below code will impersonate the user in sharepoint to add the code in the list by using domain account  using System; using System.Collections.Generic; using System.Linq; using System.Text; //SharePoint namespace using Microsoft.SharePoint.Client; namespace AddItemsToList { class Program { static void Main(string[] args) { string siteUrl = "http://sharepointserver.com"; ClientContext clientContext = new ClientContext(siteUrl); clientContext.Credentials = newSystem.Net.NetworkCredential(@"domain/userName", "password","domain.com"); Web site = clientContext.Web; //Getting List List list = site.Lists.GetByTitle("Students"); //Adding Items to List ListItemCreationInformation listItemCreationInformation = newListItemCreationInformation(); ListItem listItem = list.AddItem(listItemCreationInformation); li