Skip to content

Instantly share code, notes, and snippets.

@sksnips
sksnips / GetGroupUsers.cs
Created December 24, 2015 11:18
Get associated users from SharePoint Group using Managed Client Side Object Model
using System;
using System.Linq;
using System.Net;
using System.Text;
using System.Collections.Generic;
using Microsoft.SharePoint.Client;
namespace spknowledge.csomsamples.GetGroupUsers
{
class Program
@sksnips
sksnips / GetSiteGroups.cs
Created December 24, 2015 11:20
CS snippet used to retrieve the available site groups from the SharePoint site
using System;
using System.Linq;
using System.Net;
using System.Text;
using System.Collections.Generic;
using Microsoft.SharePoint.Client;
namespace spknowledge.csomsamples.GetSiteGroups
{
class Program
@sksnips
sksnips / GetWebGroups.cs
Created December 24, 2015 11:22
CS snippet retrieves all the Groups with permissions associated to the SharePoint Web using Managed Client Side Object Model
using System;
using System.Linq;
using System.Net;
using System.Text;
using System.Collections.Generic;
using Microsoft.SharePoint.Client;
namespace spknowledge.csomsamples.GetWebGroups
{
class Program
@sksnips
sksnips / managatimezone.cs
Created December 24, 2015 11:23
Gets the current Time Zone settings from the given SharePoint site and update with a new Time zone settings to the SharePoint online site using Managed Client Object Model
// CSOM Package (16.1.3912.1204)
// Gets and sets the current Time Zone settings from the given SharePoint site
// Get access to source site
using (var ctx = new ClientContext("https://spknowledge.sharepoint.com"))
{
//Provide count and pwd for connecting to the source
var passWord = new SecureString();
foreach (char c in "<mypassword>".ToCharArray()) passWord.AppendChar(c);
ctx.Credentials = new SharePointOnlineCredentials("<office 365 mail id>", passWord);
@sksnips
sksnips / getwebdetails.html
Created December 24, 2015 11:24
HTML snippet is used to retrieve the creation date and modified date of a web site using JSOM
<!-- How to get the Created date and Last Modified date of a Site -->
<!-- HTML Content -->
<div id="myapp"></div>
<!-- Script Content -->
<script type='text/javascript'>
var oWeb;
function getwebdetails()
{
var clientContext = SP.ClientContext.get_current(); // equivalent to SPContext.Current
oWeb = clientContext.get_web(); //Gets the current Web Object
@sksnips
sksnips / getwebtitle-jsom.html
Created December 24, 2015 11:27
HTML snippet used to retrieve the SharePoint web title using jsom
<!-- HTML Content -->
<div id="myapp"></div>
<!-- Script Content -->
<script type='text/javascript'>
var oWeb;
function getwebtitle()
{
var clientContext = SP.ClientContext.get_current(); // equivalent to SPContext.Current
oWeb = clientContext.get_web(); //Gets the current Web Object
clientContext.load(oWeb);
@sksnips
sksnips / listswoversion-rest-jq.html
Created December 24, 2015 11:32
The html snippet returns the collection of lists that are not version enabled using REST API with the help of jQuery
<!-- HTML snippet returns the collection of lists that are not version enabled -->
<!-- listswoversion.html - Lists with out version -->
<style type="text/css">
.lst-table th{ background-color:#ddd; border:2px solid #fff; text-align:left}
.lst-table td{ background-color:#eee; border:2px solid #fff;}
.web-heading{ padding:2px;}
</style>
<!--Include jQuery library to perform dynamic html dom manipulation -->
<script type="text/javascript" src="/siteassets/jquery.js"></script>
<div>
@sksnips
sksnips / listswversion-rest-jquery.html
Created December 24, 2015 11:33
HTML snippet returns the collection of lists that are version enabled using REST API with the help of jQuery
<!-- HTML snippet returns the collection of lists that are version enabled -->
<!-- listswversion-rest-jQuery.html - Lists with version -->
<!-- Style required for HTML Snippet -->
<style type="text/css">
.lst-table th{ background-color:#ddd; border:2px solid #fff; text-align:left}
.lst-table td{ background-color:#eee; border:2px solid #fff;}
.web-heading{ padding:2px;}
</style>
<!--Include jQuery library to perform dynamic html dom manipulation -->
<script type="text/javascript" src="/siteassets/jquery.js"></script>
@sksnips
sksnips / accessfolderfiles-rest-ang.html
Created December 24, 2015 11:35
Working with folders & files from SharePoint site using Angular JS & REST API
<style type="text/css">
.files-table th{ background-color:#ddd; border:2px solid #fff; text-align:left}
.files-table td{ background-color:#eee; border:2px solid #fff;}
.web-heading{ padding:2px;}
</style>
<!-- HTML Snippet -->
<script type="text/javascript" src="/siteassets/angular.min.js"></script>
<div ng-app="spng-App">
<h2 class="web-heading">Folder and Files</h2>
<div ng-controller="spng-WebCtrl">
@sksnips
sksnips / rootwebdetails-rest-jquery.html
Created December 24, 2015 11:36
Get root website information from SharePoint using Rest api with the help of jQuery
<!-- HTML snippet returns the values for properties associated to the root web in sharepoint -->
<script type = "text/javascript" src = "/siteassets/jquery.min.js" > </script>
<script type="text/javascript">
//jQuery ajax used to call the REST API and get the response
jQuery.ajax({
url: "https://sharepointsite/_api/site/rootweb",
type: "GET",
headers: {
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose",