Skip to content

Instantly share code, notes, and snippets.

@sksnips
sksnips / GetListAuthor.cs
Created December 24, 2015 16:46
This example retrieves the author who created a SharePoint list using managed client side object model
using System;
using System.Linq;
using System.Net;
using System.Text;
using System.Xml;
using System.Collections.Generic;
using Microsoft.SharePoint.Client;
namespace spknowledge.csomsamples.GetListAuthor
{
@sksnips
sksnips / getlistauthor-som.cs
Created December 24, 2015 18:15
This snippet used to retrieve the author name of the SharePoint List using Server Object Model
using System;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SharePoint;
namespace spknowledge.somexamples.GetListFolder
{
class Program
{
@sksnips
sksnips / GetFirstStageRecyclebinItems.cs
Created December 28, 2015 05:31
Retrieves the deleted items from RecycleBin (FirstStage) using CSOM
//CSOM Assembly version - 16.1.4727.1200
//using Microsoft.SharePoint.Client
//GetFirstStageRecyclebinItems(credentials, weburl);
private static void GetFirstStageRecyclebinItems(SharePointOnlineCredentials credentials, string weburl)
{
RecycleBinItemCollection recyclebinItems = null;
using (ClientContext ctx = new ClientContext(weburl))
{
@sksnips
sksnips / tenantsitecollections.cs
Created December 30, 2015 00:56
Retrieves the list of site collections available in SharePoint Online Tenant
//using Microsoft.SharePoint.Client;
//using Microsoft.Online.SharePoint.TenantAdministration;
//string weburl = "https://site-admin.sharepoint.com";
//GetSiteCollections(credentials, weburl);
//This method returns the count of Site Collections available in the tenant
//Also returns thr url of all site collections
private static void GetSiteCollections(SharePointOnlineCredentials credentials, string weburl)
{
@sksnips
sksnips / getsitewebscount.cs
Last active December 30, 2015 05:38
Get the count of all websites in sharepoint online sitecollection using CSOM
//using Microsoft.SharePoint.Client;
//using Microsoft.Online.SharePoint.TenantAdministration;
//string weburl = "https://site-admin.sharepoint.com";
//GetSite(credentials, weburl);
//This method returns the site collection object based on the url.
//shows the count of all subwebs available with in SharePoint online Site Collection
//Microsoft.Online.SharePoint.TenantAdministration.SiteProperties.WebsCount property
private static void GetSite(SharePointOnlineCredentials credentials, string weburl)
@sksnips
sksnips / gethiddenlists.cs
Created December 31, 2015 06:55
Retrieve only the hidden lists from SharePoint web using CSOM
//using Microsoft.SharePoint.Client;
//GetHiddenLists(credentials, weburl);
//This method returns the hidden lists from the web
private static void GetHiddenLists(ICredentials credentials, string weburl)
{
using (ClientContext ctx = new ClientContext(weburl))
{
ctx.Credentials = credentials;
Web oweb = ctx.Web;
@sksnips
sksnips / getnonhiddenlists.cs
Created December 31, 2015 08:33
Retrieve the non hidden lists from SharePoint web using CSOM
//using Microsoft.SharePoint.Client;
//using System.Net
//GetNonhiddenLists(credentials, weburl);
//This method returns the lists from the web, which are visible to users
private static void GetNonhiddenLists(ICredentials credentials, string weburl)
{
using (ClientContext ctx = new ClientContext(weburl))
{
ctx.Credentials = credentials;
@sksnips
sksnips / GetAllLists.cs
Created December 31, 2015 08:39
Retrieve all the lists and libraries using SharePoint website using CSOM
//using Microsoft.SharePoint.Client;
//using System.Net
//GetAllLists(credentials, weburl);
//This method returns all the lists and libraries from SharePoint website
private static void GetAllLists(ICredentials credentials, string weburl)
{
using (ClientContext ctx = new ClientContext(weburl))
{
ctx.Credentials = credentials;
@sksnips
sksnips / getgithubgists.js
Created January 7, 2016 04:41
Retrieve github gist information from browser console
//Author - Shantha Kumar T
//This Javascript snippet to get the gists details from gist web page through browser console
//
var snips = document.getElementsByClassName("gist-snippet");
for(i=0; i< snips.length; i++){
var strvalue = "";
var sniname = snips[i];
var nn = $(sniname).find('.css-truncate-target');
strvalue += "Title: " + $(nn).text().trim()+"\r\n";
strvalue += "Link: "+ location.protocol+"//"+location.hostname+$(nn).parent().attr('href')+"\r\n";
@sksnips
sksnips / webroledefinitioans-rest-jQuery.html
Created January 7, 2016 14:43
This code snippet returns the collection of role definitions attached to the web
<!-- Author: Shantha Kumar T -->
<!-- HTML snippet returns the collection of role definitions attached to the web -->
<!-- webroledefinitioans-rest-jQuery.html - Role definitins associated to the web -->
<!-- Style required for HTML Snippet -->
<style type="text/css">
.tbl-roles th{ background-color:#ddd; border:2px solid #fff; text-align:left}
.tbl-roles td{ background-color:#eee; border:2px solid #fff;}
.web-heading{ padding:2px;}
</style>
<!--Include jQuery library to perform dynamic html dom manipulation -->