Microsoft ® Official Course Working with SharePoint Objects Microsoft SharePoint 2013 SharePoint Practice.

Slides:



Advertisements
Similar presentations
Developing for SharePoint with Visual Studio Jason Keicher
Advertisements

Microsoft ® Official Course Client-Side SharePoint Development SharePoint Practice Microsoft SharePoint 2013.
Microsoft Patterns and Practices SharePoint Guidance Robert L. Bogue MS MVP, MCSE, MCSA: Security
St. Louis Day of Dot Net 2011 Jump Start: SharePoint Development Becky Bertram Independent SharePoint Consultant SharePoint MVP, MCSD.NET, MCTS
Microsoft ® Official Course Creating Robust and Efficient Apps for SharePoint Microsoft SharePoint 2013 SharePoint Practice.
Microsoft ® Official Course Interacting with the Search Service Microsoft SharePoint 2013 SharePoint Practice.
Microsoft SharePoint 2013 SharePoint 2013 as a Developer Platform
Microsoft ® Official Course Working with Lists and Libraries Microsoft SharePoint 2013 SharePoint Practice.
Microsoft ® Official Course Working with Branding and Navigation Microsoft SharePoint 2013 SharePoint Practice.
Managing Identity and Permissions
Microsoft ® Official Course Developing Remote-hosted Apps for SharePoint Microsoft SharePoint 2013 SharePoint Practice.
Microsoft ® Official Course Developing Optimized Internet Sites Microsoft SharePoint 2013 SharePoint Practice.
Microsoft ® Official Course Publishing and Distributing Apps Microsoft SharePoint 2013 Sriram – SharePoint Practice.
Microsoft ® Official Course Introducing Apps for SharePoint SharePoint Practice Microsoft SharePoint 2013.
Microsoft ® Official Course Developing Managed Metadata Solutions Microsoft SharePoint 2013 SharePoint Practice.
SharePoint 2010 Business Intelligence Module 3: Business Intelligence Center.
Fraser Technical Solutions, LLC
SPC220 Web Template FundamentalsCreating Web Templates Using Web Templates Web Templates and App Webs Wrap Up.
Microsoft ® Official Course Monitoring and Troubleshooting Custom SharePoint Solutions SharePoint Practice Microsoft SharePoint 2013.
WSS 3.0 Architecture and Enhancements Ashvini Shahane Member – Synergetics Research Lab.
Microsoft ® Official Course Module 9 Configuring Applications.
Windows.Net Programming Series Preview. Course Schedule CourseDate Microsoft.Net Fundamentals 01/13/2014 Microsoft Windows/Web Fundamentals 01/20/2014.
Module 12 Installing and Upgrading to SharePoint 2010.
Deployment of web Site. Preparing the web site for deployment you now have two versions of web site 1 -one running in the production environment 2-one.
HTML5 Application Development Fundamentals
Implementing File and Print Services
Module 8 Configuring and Securing SharePoint Services and Service Applications.
Module 14: WCF Send Adapters. Overview Lesson 1: Introduction to WCF Send Adapters Lesson 2: Consuming a Web Service Lesson 3: Consuming Services from.
OBJECT REFERENCE. Objective How to work with objects in SharePoint by using classes?
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Workflow Development Overview Architecture Requirements Types of workflows Stages of workflow.
Eric Maurer Copyright Keller Schroder  Windows SharePoint Services 3.0 Tools: Visual Studio 2005 Extensions, Version 1.1  Windows SharePoint Services.
Microsoft SharePoint Server 2010 for the Microsoft ASP.NET Developer Yaroslav Pentsarskyy
HOW SHAREPOINT WORKS By Gary Newman. Root Folder Virtual Directories SP Farm DNS Iterative Forward DNS query for A host record HTTP request HTML & JS.
Module 14 Configuring Security for SQL Server Agent.
Module 10 Administering and Configuring SharePoint Search.
Module 7: Accessing Data by Using ADO.NET
New & Improved Events List Relationships and Joins Large List Support Field & List Item Validation.
Module 3 Configuring File Access and Printers on Windows 7 Clients.
Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. SharePoint API and Development in ASP.NET Creating “Hello World” application Working with.
3 Copyright © 2004, Oracle. All rights reserved. Working in the Forms Developer Environment.
What’s New in SharePoint 2010 SharePoint 2010 Development Primer New Developer Tools for SharePoint 2010 SharePoint 2010 Integration with PowerShell.
Module 14 Application Settings, State, and Life Cycle.
Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Security Overview Functional security – users, groups, and permissions for sites, lists,
Configuring and Troubleshooting Identity and Access Solutions with Windows Server® 2008 Active Directory®
Microsoft ® Official Course Structuring and Publishing Websites for All Users Microsoft SharePoint 2013 SharePoint Practice.
Microsoft ® Official Course Developing a Publishing Site for Web Content Microsoft SharePoint 2013 SharePoint Practice.
Module 9: Using XML Web Services in a C# Application.
Module 9 User Profiles and Social Networking. Module Overview Configuring User Profiles Implementing SharePoint 2010 Social Networking Features.
Module 4: Creating a Web Application with Web Forms
Understanding Web Applications Lesson 4. Objective Domain Matrix Skills/ConceptsMTA Exam Objectives Understanding Web Page Development Understand Web.
Module 4 Taking Control of the User Interface. Module Overview Sharing Logical Resources in an Application Creating Consistent User Interfaces by Using.
Preface IIntroduction Objectives I-2 Course Overview I-3 1Oracle Application Development Framework Objectives 1-2 J2EE Platform 1-3 Benefits of the J2EE.
Microsoft ® Official Course Designing and Managing Features and Solutions Microsoft SharePoint 2013 SharePoint Practice.
Microsoft ® Official Course Implementing Enterprise Content Management Microsoft SharePoint 2013 SharePoint Practice.
Module 4: Administering Microsoft Office SharePoint Server 2007.
Module 2: Using ADO.NET to Access Data. Overview ADO.NET Architecture Creating an Application That Uses ADO.NET to Access Data Changing Database Records.
Application Hosting and Customization Introducing Sandboxed Solutions Executing Code in the Sandbox Sandbox Resource Monitoring.
Windows SharePoint Services Development Part 1: Paul Appleby Application Architect Microsoft Limited.
Microsoft ® Official Course Module 9 Working with Business Connectivity Services.
A Developer’s Introduction to SharePoint 2013 Apps Ryan McIntyre, MCITP, MCPD National
Module 6: Configuring and Managing Windows SharePoint Services 3.0.
PowerShell 101 sharepoint on-premise
Working in the Forms Developer Environment
Remote Event Receivers
Working with Server-Side Code
Migration to SharePoint 2013
03 | Client Side SharePoint Development
Mike Ammerlaan Program Manager Microsoft Corporation
Managing Custom Components and Site Life Cycles
Presentation transcript:

Microsoft ® Official Course Working with SharePoint Objects Microsoft SharePoint 2013 SharePoint Practice

Module Overview Understanding the SharePoint Object Hierarchy Working with Sites and Webs Working with Execution Contexts

Lesson 1: Understanding the SharePoint Object Hierarchy The SharePoint Object Hierarchy The SPFarm Class Working with Services Working with Service Applications Discussion: Understanding the Service Application Architecture Working with Web Applications Site Collections and the SPSite Class Individual Sites and the SPWeb Class

The SharePoint Object Hierarchy SPFarm SPService SPWebApplication SPSite SPWeb SPList SPServiceApplication All arrows represents one- to-many relationships

The SPFarm Class Highest-level object in the hierarchy Represents farm-wide configuration Instantiate through the static Local property Use properties and methods to retrieve configuration settings SPFarm farm = SPFarm.Local; Guid farmID = SPFarm.Local.Id; Bool isAdmin = SPFarm.Local.CurrentUserIsAdministrator();

Working with Services Service classes SPService represents a farm-scoped service SPServiceInstance represents an instance of an SPService on a specific server The SPWebService class Container for web applications ContentService AdministrationService Scope Not available in SharePoint Online Not available in sandboxed solutions or client-side code

Working with Service Applications Service Application SPServiceApplication Service Application SPServiceApplication Service Application Proxy SPServiceApplicationProxy Service Application Proxy SPServiceApplicationProxy Web Application SPWebApplication Web Application SPWebApplication Service Application Proxy Group SPServiceApplicationProxyGroup Service Application Proxy Group SPServiceApplicationProxyGroup

Discussion: Understanding the Service Application Architecture Why have service application proxies? Why have service application proxy groups?

Working with Web Applications Containers for site collections Map SharePoint content to IIS websites Represented by the SPWebApplication class var contentService = SPWebService.ContentService; SPWebApplication webApp = contentService.WebApplications["Display Name"]; webApp.MaximumFileSize = 75; webApp.Update();

Site Collections and the SPSite Class Container for individual sites Security boundary Deployment scope for many artifacts Various ways to instantiate: // Supply a URL. var site1 = new SPSite(" // From the parent SPWebApplication instance. var site2 = webApp.Sites["team.contoso.com"]; // From the execution context. var site3 = SPContext.Current.Site;

Individual Sites and the SPWeb Class Container for lists and libraries Container for child SPWeb objects Every site collection contains one root web Various ways to instantiate: // From the parent SPSite instance. var web1 = site.RootWeb; var web2 = site.AllWebs["finance"]; var web3 = site.OpenWeb("finance"); // From the execution context. var web4 = SPContext.Current.Web;

Lesson 2: Working with Sites and Webs Managing Object Life Cycles Retrieving and Updating Properties Demonstration: Updating Properties Creating and Deleting Sites and Webs

Managing Object Life Cycles SPSite and SPWeb objects are memory-intensive Developers must manage the object life cycle Disposal guidelines: If you instantiated the object, dispose of it If you referenced an existing object, do not dispose of it Disposal patterns: try-catch-finally blocks using blocks

Retrieving and Updating Properties Retrieving properties Updating properties SPWeb web = SPContext.Current.Web; // Retrieve a simple property. string title = web.Title; // Retrieve a collection property. SPListCollection lists = web.Lists; foreach (SPList list in lists) {... } // Update various properties. web.Title = "New Title"; web.Description = "A brand new description."; // Write the changes to the content database. web.Update();

Demonstration: Updating Properties In this demonstration, you will see an example of how to update the properties of an SPWeb object.

Demonstration: Updating Properties

Creating and Deleting Sites and Webs Creating sites and webs Call the Add method on a collection object Deleting sites and webs Call the Delete or Recycle method on the object You must still dispose of the object properly SPSite site = SPWeb web = site.AllWebs.Add("project1"); SPWeb web = site.OpenWeb("project1"); web.Delete(); web.Dispose();

Lab A: Working with Sites and Webs Exercise 1: Working with Sites and Webs in Managed Code Exercise 2: Working with Sites and Webs in Windows PowerShell.

Lab Scenario The management team at Contoso has complained that project sites across the organization use a variety of different naming conventions. They have asked you to find an efficient way to update several site titles. In this lab, you will prototype two different approaches. First, you will use a visual Web Part to enumerate sites and enable users to update site properties. You will then experiment with performing the same procedure in Windows PowerShell.

Lab Review Which approach would you recommend to the management team: the visual Web Part or the Windows PowerShell script? Why? What happens if a user with insufficient permissions loads the Web Part? How would you work around any issues caused by insufficient permissions? Enumerating sites and webs is computationally expensive. Why is this particularly problematic in a Web Part?

Lesson 3: Working with Execution Contexts Understanding the SharePoint Context Working with Users and Permissions Discussion: Adapting Content for Different User Permissions Manipulating the Execution Context

Understanding the SharePoint Context SPContext object Represents context of current HTTP request Provides a range of information: Only available when your code is invoked synchronously by an HTTP request SPSite currentSite = SPContext.Current.Site; SPWeb currentWeb = SPContext.Current.Web; SPUser currentUser = SPContext.Current.Web.CurrentUser;

Working with Users and Permissions Verifying permissions programmatically Using security trimming var web = SPContext.Current.Web; if(web.DoesUserHavePermissions( SPBasePermissions.ManageWeb)) { // Perform the update operation. } <SharePoint:SPSecurityTrimmedControl runat="server" PermissionsString="ManageWeb">

Discussion: Adapting Content for Different User Permissions When should you use code to adapt content to the permissions of the current user? When should you use the SPSecurityTrimmedControl to adapt content to the permissions of the current user?

Manipulating the Execution Context Use SPSecurity.RunWithElevatedPrivileges to run code using the system account var delegateDPO = new SPSecurity.CodeToRunElevated(DoPrivilegedOperation); SPSecurity.RunWithElevatedPrivileges(delegateDPO); private void DoPrivilegedOperation() { // This method will run with elevated privileges. } SPSecurity.RunWithElevatedPrivileges(delegate() { // This code will run with elevated privileges. });

Lab B: Working with Execution Contexts Exercise 1: Running Code with Elevated Privileges Exercise 2: Adapting Content for Different User Permissions

Lab Scenario In this lab, you will modify the visual Web Part you created in the previous exercise to make sure it renders correctly for all users. You want to display the list of webs to all users, so you will adapt the code that populates the list box to run with elevated privileges. However, you only want the update controls to be visible to users who have the permissions required to update web titles, so you will wrap the update controls in an SPSecurityTrimmedControl element.

Module Review and Takeaways Review Question(s)

Module Review and Takeaways Review Question(s)

Module Review and Takeaways Review Question(s)