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 […]

Convert any time format to web time zone format presents in SharePoint site

Generally Last modified time of SharePoint site or SharePoint list or SharePoint list item is in UTC (Universal Time Coordinated) format and if SharePoint time zone format is not UTC format then result of last modified time such as (web.LastItemModifiedDate) seems incorrect. So it has to convert time into correct format of sharepoint web time zone. Steps:- Add reference “Microsoft.sharepoint.client.dll” […]

Retrieve users and groups from Active Directory (AD)

Below code describes how to get all users and all groups from active directory (AD Server) Using System.DirectoryServices Steps:- Add System.Directoryservices.dll and System.Directoryservices.AccountManagement.dll which provides access to active directory. Using System.DirectoryServices.AccountManagement I have used a generic list (collection of string) to store account name of user and group.   class Program { static void Main(string[] args) {  List<string> _userOrGroupColl = […]

Add default site columns to list using Client Object Model

Below code describes how to add site columns from site to SharePoint list. Add reference “Microsoft.sharepoint.client.dll” and “Microsoft.sharepoint.client.Runtime.dll”. Write Below Code. class Program { static void Main(string[] args) { string listName = “New List”; using (ClientContext context = new ClientContext(“siteUrl”)) { context.Credentials = new System.Net.NetworkCredential(“UserName”, “Password”); //Apply Credential Web web = context.Web; context.Load(web, w => w.AvailableFields, w => w.Lists); List […]