Excellence in Software Engineering
Download
Report
Transcript Excellence in Software Engineering
MS SharePoint CSOM
Client-Side Object Model
Belarus SharePoint User Group © 2012, by Ivan Padabed
CONTENT CC: DOCUMENTUM
SharePoint Data Access
New for 2010
2007 technologies
LINQ
SPQuery
SiteMap Provider
REST
Cross-site query
Client OM
Silverlight
WCF
2
Data Access
• Use JSON / XML
SharePoint Data
• Client technologies:
– WPF
SharePoint API
– WinForm
– Office
– Silverlight
Client.svc
– Javascript
Client Application
3
Main objects: User Interface
Site
Web
Form
List
View
Folder
File
Navigation
NavigationNode
WebPart
UserCustomAction
4
Main objects: Data and Schema
Site
Web
Field
List
ListItem
Folder
File
Change
ContentType
5
Main objects: Logic and Security
Site
Web
RoleDefinition
RoleAssignment
WorkflowAssociation
WorkflowTemplate
6
Basics
• Batch operations
• Execute Query
7
Hints
• Only Foundation functionality
– No search, profiles, metadata, administration
• No privileges elevation
• Requests are throttled
• Execution model:
– .NET CLR can be sync
– SL/JS are async only
• O365 Support
8
Authentication Support: FBA
using (ClientContext ctx = new ClientContext(https://mysite))
{
FormsAuthenticationLoginInfo fbaInfo =
new FormsAuthenticationLoginInfo(“user”, “pwd”);
ctx.AuthenticationMode =
ClientAuthenticationMode.FormsAuthentication;
ctx.FormsAuthenticationLoginInfo = fbaInfo;
}
9
Authentication Support: Impersonation
using (ClientContext ctx = new ClientContext(https://mysite))
{
NetworkCredential cred =
new NetworkCredential(“user”, “pwd”, “domain”);
ctx.AuthenticationMode =
ClientAuthenticationMode.Default;
ctx.Credentials = cred;
}
10
Anonymous Access
• Blocked functionality
– GetItems, GetChanges on SPList
– GetChanges, GetSubwebsForCurrentUser on
SPWebs
– GetChanges on SPSites
• Get it back by WebApp PS:
$app.ClientCallableSettings.AnonymousRestrictedTypes.
Remove([microsoft.sharepoint.splist], “GetItems”)
11
SilverLight specifics
• SL context from init params
<param name = \”initParams\” value = \”MS.SP.url=“ +
SPContext.Current.Site.Url + “\”/>”
• Enables ClientContext.Current
12
Cross-domain (protocol/port) access
• clientaccesspolicy.xml
• crossdomain.xml
• Use proxy
13
CSOM examples
• MySiteSync
– dropbox with SP
• DWH builder with SSIS
– import data to warehouse from SSIS
• Quick utilities, incl SPD
– get GUIDs, etc
14