36
SharePoint Saturday Sponsors Gold Silver Bronze Programming SharePoint and Office 365 on the Client Side Elaine van Bergen OBS

Sps bris - Customising Office 365 on the Client side

Embed Size (px)

DESCRIPTION

Presentation delivered at SharePoint saturday brisbane on sandboxed solutions, CSOM, exchange API and authentication with 365

Citation preview

Page 1: Sps bris - Customising Office 365 on the Client side

SharePoint SaturdaySponsorsGold

Silver

Bronze

Programming SharePoint and Office 365

on the Client Side

Elaine van BergenOBS

Page 2: Sps bris - Customising Office 365 on the Client side

SharePoint Saturday Brisbane 2012

Topics• Sandboxed Solutions• Client Object Models• Exchange Office 365 API• Authentication

Page 3: Sps bris - Customising Office 365 on the Client side

SharePoint Saturday Brisbane 2012

Setup Development Environment

• Enable Microsoft SharePoint Foundation Sandboxed Code Service via CA

• Download power toolshttp://visualstudiogallery.msdn.microsoft.com/8e602a8c-6714-4549-9e95-f3700344b0d9

• Download Silverlight toolkithttp://www.microsoft.com/web/gallery/install.aspx?appid=silverlight4tools;silverlight4toolkit;riaservicestoolkit

Page 4: Sps bris - Customising Office 365 on the Client side

Sandbox Execution

Sandbox Worker Process(SPUCWorkerProcess.exe)

User Code Service (SPUCHostService.exe)Execution Manager

(Inside Application Pool)

IIS(WPW3.EXE)

FRONT END

Sandbox Worker Proxy Process(SPUCWorkerProcessProxy.exe)

Full SP Object Model

SP Object Model Subset

Untrusted Code

Web.config / CAS Policies

Subset-Model Request

Access restricted

by CAS policy

BACK END

Page 5: Sps bris - Customising Office 365 on the Client side

SharePoint Saturday Brisbane 2012

Sandboxed Solutions SupportItem Template Sandbox

Compatible?Visual Web Part NoVisual Web Part (Sandboxed) Yes

Web Part YesSequential Workflow NoState Machine Workflow NoBusiness Data Connectivity Model

No

Application Page NoEvent Receiver YesModule YesContent Type YesList Definition From Content Type

Yes

List Definition YesList Instance YesEmpty Element YesUser Control No

Page 6: Sps bris - Customising Office 365 on the Client side

SharePoint Saturday Brisbane 2012

API Scope• Subset of Microsoft.SharePoint• Scoped to SPSite/Site Collection and below– Site Columns– Content Types– List Definitions– List Instances– Web Parts– Workflows– Custom Actions– SharePoint Designer workflow activities– Event Receivers– Modules/Files

Page 7: Sps bris - Customising Office 365 on the Client side

SharePoint Saturday Brisbane 2012

Unsupported Features

• Anything above the site collection• Access to External Code/Data• Creation of SPWeb/SPSite outside of context• SPSecurity• BCS (WCF service supported)

Page 8: Sps bris - Customising Office 365 on the Client side

SharePoint Saturday Brisbane 2012

Sandbox Deployment

Upload

Activation

DeactivationDeletion

Upgrade

Page 9: Sps bris - Customising Office 365 on the Client side

SharePoint Saturday Brisbane 2012

Solution Monitoring

• Protects Site Collection from resource intensive solutions

• Resource Points measure resource consumption

• Site Collection Quota limits resource consumption per day

• Absolute Limit limits resources consumed by a solution

Page 10: Sps bris - Customising Office 365 on the Client side

Monitored ResourcesMetric Name Description Units Resources

Per PointAbsoluteLimit

AbnormalProcessTerminationCount Process gets abnormally terminated Count 1 1

CPUExecutionTime CPU exception time Seconds 3,600 60CriticalExceptionCount Critical exception fired Number 10 3

InvocationCount Number of times solution has been invoked Count N/A N/A

PercentProcessorTime Note: # of cores not factored inPercentage Units of Overall Processor Consumed

85 100

ProcessCPUCycles CPU Cycles 1E+11 1E+11ProcessHandleCount Windows Handles 10,000 1,000

ProcessIOBytes (Hard Limit Only) Bytes written to IO Bytes 0 1E+08

ProcessThreadCount Number of Threads in Overall Process Threads 10,000 200

ProcessVirtualBytes (Hard Limit Only) Memory consumed Bytes 0 1E+09

SharePointDatabaseQueryCount SharePoint DB Queries Invoked Number 20 100

SharePointDatabaseQueryTime Amount of time spent waiting for a query to be performed Seconds 120 60

UnhandledExceptionCount Unhanded Exceptions 50 3

UnresponsiveprocessCount We have to kill the process because it has become unresponsive Number 2 1

Page 11: Sps bris - Customising Office 365 on the Client side

SharePoint Saturday Brisbane 2012

SharePoint 2010 Approach• Developers build

custom solutions• Administrators leverage

resource monitors to check site collection usage

• Site collection owners deploy, activate and implement the customizations

Developer • Design, build and test

customizations

Administrator• Monitor customizations

Site Collection Owner• Activate and use

customizations• Install customizations

Page 12: Sps bris - Customising Office 365 on the Client side

SharePoint Saturday Brisbane 2012

SANDBOXED SOLUTIONDEMO

Page 13: Sps bris - Customising Office 365 on the Client side

SharePoint Saturday Brisbane 2012

Sandboxed Solution Summary• Easy Deployment Model – No coffee break• Limited functionality

Page 14: Sps bris - Customising Office 365 on the Client side

SharePoint Saturday Brisbane 2012

Why Client Object Model?• More SharePoint Web services

is a major request• Client Object Model provides more complete API

instead of more services• Provides an abstraction layer to return results as

recognizable SharePoint objects• Consistent developer experience across platforms

(.NET, ECMAScript, Silverlight)

Page 15: Sps bris - Customising Office 365 on the Client side

SharePoint Saturday Brisbane 2012

Supported Areas

• Site Collections and Sites• Lists, List Items, Views, and List Schemas• Files and Folders• Web, List, and List Item Property Bags• Web Parts• Security• Content Types• Site Templates and Site Collection Operations

Page 16: Sps bris - Customising Office 365 on the Client side

SharePoint Saturday Brisbane 2012

Client.svc

Server OM

Contentdatabase

ECMAScript OM

Proxy

Managed OM

Proxy

Managed Controls and Logic

ECMAScriptControlsand Logic

XML Request

XML Request

JSON Response

JSON Response

Browser

Managed Client

SharePoint Server

Page 17: Sps bris - Customising Office 365 on the Client side

SharePoint Saturday Brisbane 2012

Server (Microsoft.SharePoint)

.NET Managed(Microsoft.SharePoint.Client)

Silverlight(Microsoft.SharePoint.Client.Silverlight)

ECMAScript(SP.js)

SPContext ClientContext ClientContext ClientContext

SPSite Site Site Site

SPWeb Web Web Web

SPList List List List

SPListItem ListItem ListItem ListItem

SPField Field Field Field

Page 18: Sps bris - Customising Office 365 on the Client side

SharePoint Saturday Brisbane 2012

.Net Client OM• Designed for use outside of SharePoint• Can be used with .Net 4.0 • Microsoft.SharePoint.Client

Page 19: Sps bris - Customising Office 365 on the Client side

.Net ExampleClientContext clientContext = new ClientContext("http://server");

//Load methodclientContext.Load(clientContext.Web); clientContext.Load(clientContext.Web.Lists);

//LoadQuery methodvar q1 = from list          in context.Web.Lists         where list.Title != null         select list; var r1 = context.LoadQuery(q1);

Page 20: Sps bris - Customising Office 365 on the Client side

SharePoint Saturday Brisbane 2012

ECMAScript Client OM• ECMAScript Client OM is easily added to a

SharePoint ASPX page - reference:– _layouts/sp.js– Add this using <SharePoint:ScriptLink>

• All libraries crunched for performance– Use un-crunched *.debug.js by adding

<SharePoint:ScriptLink … ScriptMode=“Debug” />

• Method signatures can be different• Different data value types

Page 21: Sps bris - Customising Office 365 on the Client side

SharePoint Saturday Brisbane 2012

Silverlight Client OM

• Silverlight Development Enabled by Client OM

• Can use Silverlight in separate ASPX page or in Web Part

• Can utilize Client OM in Silverlight to create SharePoint apps

Page 22: Sps bris - Customising Office 365 on the Client side

SharePoint Saturday Brisbane 2012

Creating Silverlight Web Parts

• A Web Part can be a host for Silverlight• SharePoint ships with Silverlight web part• The web part can contain custom properties

that are sent to Silverlight via the InitParameters property

• The XAP file can be deployed to LAYOUTS and loaded at run time

• The Silverlight application can then make use of the Client OM.

Page 23: Sps bris - Customising Office 365 on the Client side

SharePoint Saturday Brisbane 2012

JAVASCRIPT CLIENT OBJECT MODELDEMO

Page 24: Sps bris - Customising Office 365 on the Client side

SharePoint Saturday Brisbane 2012

Client Object Model Summary

• 3 different versions• Need to load items to get data• Far easier than web services to get data

Page 25: Sps bris - Customising Office 365 on the Client side

SharePoint Saturday Brisbane 2012

EXCHANGE INTEGRATION

Page 26: Sps bris - Customising Office 365 on the Client side

SharePoint Saturday Brisbane 2012

EWS MA 1.1 Overview

• Managed API for developing applications that use Exchange Web Services

• Functional parity with EWS*• Makes EWS calls under the covers• Backwards compatible– Request versioning

new ExchangeService(ExchangeVersion.Exchange2010_SP1);

• Cloud compatible out of the box

Page 27: Sps bris - Customising Office 365 on the Client side

SharePoint Saturday Brisbane 2012

Autodiscover

• Don’t hardcode EWS URL in your app!• Use Autodiscover to find most efficient Client

Access Server URL for a given mailbox– On-Premise• Global & distributed deployments

– Cloud based• Office 365• Outlook Live• Live@EDU

Page 28: Sps bris - Customising Office 365 on the Client side

SharePoint Saturday Brisbane 2012

Autodiscover – Exchange Online

EXO Office 365

EWS MAApplication

EWS MA client contacts Autodiscoversevice

Autodiscover service returns URL for EWS

bindings

EWS MA client connects to Exchange Web Services

Firewall

EWS MA client executes callback to Validate URL

Redirection

Page 29: Sps bris - Customising Office 365 on the Client side

SharePoint Saturday Brisbane 2012

Impersonation

• Application performs actions using another user’s– Identity– Permissions

• Exchange ApplicationImpersonation role needs to be granted to a user

• Service account is typically allowed to impersonate other accounts

Page 30: Sps bris - Customising Office 365 on the Client side

SharePoint Saturday Brisbane 2012

OFFICE CLIENT/EXCHANGE DEMODEMO

Page 31: Sps bris - Customising Office 365 on the Client side

SharePoint Saturday Brisbane 2012

Office Client/Exchange Summary

• Easy to program against exchange• Hybrid solutions to solve business problems• Call SharePoint from business systems

Page 32: Sps bris - Customising Office 365 on the Client side

SharePoint Saturday Brisbane 2012

Page 33: Sps bris - Customising Office 365 on the Client side

SharePoint Saturday Brisbane 2012

Authentication

• Claims + Federation + Multiple Authentication Providers• FedAuth cookie with HTTP Only Flag = WinInet.dll • Active vs. Passive

COMPLICATED !

http://msdn.microsoft.com/en-us/library/hh147177.aspx http://www.wictorwilen.se/Post/How-to-do-active-authentication-to-Office-365-and-SharePoint-Online.aspx

Page 34: Sps bris - Customising Office 365 on the Client side

SharePoint Saturday Brisbane 2012

Topics• Sandboxed Solutions• Client Object Models• Exchange Office 365 API• Authentication

Page 35: Sps bris - Customising Office 365 on the Client side

SharePoint Saturday Brisbane 2012

QUESTION AND ANSWER@LANEYVB

Page 36: Sps bris - Customising Office 365 on the Client side

SharePoint Saturday

Thanks for listening!

Remember to submit your feedback so you can go into the raffle draw at the end of the day! And don’t forget that

you have to be at the draw to claim your prizes!

SponsorsGold

Silver

Bronze