Get all SharePoint site users using Client object model

[code lang=”c”] class Program { static void Main(string[] args) { using (ClientContext ctx = new ClientContext(“http://siteUrl”)) { NetworkCredential netCredentials = new NetworkCredential(“userName”, “password”); ctx.Credentials = netCredentials; try { Web web = null; web = ctx.Web; RoleAssignmentCollection assignColl; RoleAssignment roleAssign; RoleDefinitionBindingCollection bindingColl; ctx.Load(web.RoleAssignments, roles => roles.Include( r => r.Member, r => r.Member.LoginName, r => r.Member.Title, r => r.RoleDefinitionBindings )); ctx.ExecuteQuery(); assignColl […]

Retain internal name of list columns while copying list from One site to another site using client object model

Internal name is a property of list fields which is read only and cannot be edited. Internal name is created according to field title while creating field. If we rename field title internal name will not be changed. If one user has created a custom column and give title=”Column” then internal name will be “Column” After renaming field title ‘Internal […]

How to get items from a specific SharePoint List View using client object model

Below code describes how to retrieve items from sharepoint list by specific view using client side object model Add reference “Microsoft.sharepoint.client.dll” and “Microsoft.sharepoint.client.Runtime.dll”. Write Below Code. using Microsoft.SharePoint.Client; namespace ConsoleApplication {       class Program     {         static void main(string[] args)         {             using (ClientContext ctx=new ClientContext(“http://siteurl”))             {                 //Apply Credential                 ctx.Credentials […]

How to get list item version history of a custom list using Client Object Model

Below code describes how to get the list item version history of a custom list using Client Object Model Add reference “Microsoft.sharepoint.client.dll” and “Microsoft.sharepoint.client.Runtime.dll”. Write Below Code. class Program { static void Main(string[] args) { using (ClientContext ctx = new ClientContext(“SITE_URL”)) { CamlQuery camlQuery = new CamlQuery(); Web web = ctx.Web; ctx.Load(web,                     w => w.ServerRelativeUrl,                     w => w.Lists); […]

Enable or Disable Audience targeting of a list in SharePoint

Below code describes how to enable or Disable Audience targeting of a list in sharepoint using client side object model Add reference “Microsoft.sharepoint.client.dll” and “Microsoft.sharepoint.client.Runtime.dll”. Write Below Code.   using Microsoft.SharePoint.Client; namespace ConsoleApplication {       class Program     {         static void Main(string[] args)         {             using (ClientContext ctx=new ClientContext(“SiteUrl”))             {                 //Apply Credential                 ctx.Credentials = new […]