SharePoint Authentication methods overview

Window Authentication

– authentication managed by Windows Server and IIS

Forms Based Authentication

– authentication managed by ASP.NET and an authentication provider

Claims Authentication

– authentication managed by a security token service (STS

 

SharePoint creates a profile for each user a the site collection level

– User information list used to track identities

–  Identity seen by developers as SPUser

 

User information list is automatically created at the top level site.

– Tracks security principals using an integer ID

 

SharePoint may rely on external source for authentication but it controls all authorisation to its resources and entities.

CSOM – Get site object using JavaScript

Working with CSOM using JavaScript is slight different in syntax, but the process involved with getting the objects required for coding is the same! You still need to use the context object, load the context object, and execute the query that will send the context object off to SharePoint to tell it what you want and have it returned back.

The syntax is slightly different and the context return object is used in a different way:

var ctx;

var web;

var lists;

$(onPageLoad);

function onPageLoad()

{

ExecuteOrDelayUntilScriptLoaded(LoadAll, “sp.js”);

}

function LoadAll()

{

ctx = SP.ClientContext.get_current();

web = ctx.get_web();

ctx.load(web);

ctx.load(web.get_currentUser());

lists = web.get_lists();

ctx.load(lists);

ctx.executeQueryAsync(doSomething, displayError);

}

function doSomething()

{

var siteTitle = web.get_title();

var siteId = web.get_id().toString();

var siteUrl = web.get_url();

var currentUser = web.get_currentUser().get_loginName();

}

function onError(sender, args)

{

alert(JSON.stringify(args));

}

CSOM – Get lists via Managed Code

I have been working on CSOM recently and I wanted to share this snipplet of code that I used to get the Web object, List Collection, and create a new list via the client object model through managed C# code.

// Create the client context by passing in the web url I want to use

ClientContext cctx = new ClientContext(“http://phillau.com”);

cctx.Credentials = CredentialCache.DefaultCredentials;

Web ctxWeb = cctx.Web;

ListCollection lists = ctxWeb.Lists;

// Load the context object with instructions to only populate the title field in the site object

cctx.Load(site s => s.Title);

// Request gets send to retrieve the site title

cctx.ExecuteQuery();

Console.WriteLine(“Site Title:” + ctxWeb.Title);

//Create a new list. Specify what you want it to be!

ListCreationInformation list = new ListCreationInformation();

list.Title = “Ships”;

list.Url = “List/Ships”;

list.TemplateType = (int)ListTemplateType.GenericList;

// Add to list collection

web.Lists.Add(list);

// Load into context object to be launched!

cctx.Load(lists)

// Submit list blueprint!

cctx.ExecuteQuery();

foreach(List list in lists)

{

          Console.WriteLine(list.Title);

}

Done!

Core results web part: Raw XML property and result

I have come across situations while working with the core results web part xslt to display the results, I just want to see what property is retrieving what value. Raw xml is the best way forward!

Edit the core results web part, expand Display Properties, select the XSL Editor button. Inside the text box, copy the existing xslt out of the editor and paste the following into it:

<?xml version=”1.0″ encoding=”utf-8″?>

<xsl:stylesheet version=”1.0″ xmlns:xsl=”http://www.w3.org/1999/xsl/transform”&gt;

<xsl:output method=”xml” version=”1.0″ encoding=”utf-8″ indent=”yes”/>

    <xsl:template match=”/”>

         <xmp>

              <xsl:copy-of select=”*”/>

       </xmp>

</xsl:template>

</xsl:stylesheet>

Click OK and save the page.

Reload the page and the Raw XML will be displayed for search results!

Handy xsl 🙂