1 / 41

NET Development on Microsoft Windows SharePoint Services (WSS) 3.0: The WSS Object Model

OFC330 . NET Development on Microsoft Windows SharePoint Services (WSS) 3.0: The WSS Object Model . Patrick Tisseghem Managing Partner U2U patrick@u2u.net. Session Objectives And Agenda. WSS Object Model Fundamentals. Working Remotely with Lists and Document Libraries.

cody
Download Presentation

NET Development on Microsoft Windows SharePoint Services (WSS) 3.0: The WSS Object Model

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. OFC330 NET Development on Microsoft Windows SharePoint Services (WSS) 3.0: The WSS Object Model Patrick Tisseghem Managing Partner U2U patrick@u2u.net

  2. Session Objectives And Agenda WSS Object Model Fundamentals Working Remotely with Lists and Document Libraries Cross-Site Data Queries Event Handlers Exploring New WSS Classes

  3. Object Models Download the SDK!!!! There isalso the .NET Reflectoron www.aisto.com/roeder

  4. Wherecan I use the WSS OM? • Web Parts • ASP.NET Custom Controls and User Controls • Application pages • Feature activation event handlers • Event handlers for lists, doc libs, sites & site collections • ASP.NET applications and Web services • Windows Forms and Console applications WSS Sites WSS Object Model Web Services Web PartsWeb Pages Smart Clients Smart andMobile Clients

  5. SPFarm SPWebServer SPWebApplication SPSite HighBackward Compatibility With WSS v2 Some classes are obsolote -SPGlobalConfig -SPVirtualServer SPWeb SPList SPListItem

  6. SPSite Object • Represents site collection • User must be authenticated and authorizedunless anonymous access is enabled • Site Collection has an owner • Site Collection contains hierarchy of child site

  7. SPWeb Objects • Sites accessible through SPWeb objects • Often must use SPSite object to access SPWeb objects

  8. Calling Dispose • Many WSS OM objects follow IDisposable pattern • They use unmanaged resources that must be released • Failure to call Dispose can cause serious memory leakage

  9. SPList and SPListItem • Lists are modeled using SPList objects • Items modeled using SPListItem objects • Document libraries can be accessed using SPList

  10. SPFile and SPFolder • Site represents hierarchy of files and folders • Files represented through SPFile objects • Folders represented through SPFolder objects • What can be done? • Discover all files and folders within a site • Add, move, copy, delete files and folders • Return a page to its initial ghosted state • Program against Web Part data on a Web Part Page

  11. SPDocumentLibrary • Document Library is more than a SPList object • Can convert SPList to SPDocumentLibrary • Make extra functionality accessible

  12. demo Exploring SharePoint using the Object Model

  13. Security-Related Changes • Impersonatingusing the SPSiteconstructor • ElevatingPrivileges • The ISecurableObject Interface Don’tforget: Test your Web Parts withthe least security permissions!

  14. What’s happening by default? • Web Part code is executed with the account of the logged-on user • Impersonation done by SharePoint • Handle this elegantly!

  15. Impersonating • Constructor of SPSite accepts now an SPUserToken used to impersonate a specific user • Tokens time out after 24 hours • Web Part requires SharePointPermission with Impersonate option

  16. Elevating Permissions • Some aspects of WSS OM require privileged users • Run your code with the SharePoint\System account • Use with care! The behavior has been created by design (not a mistake!) • SPSecurity.RunWithElevatedPrivileges solves many problems • Web Parts must have the ‘SharePointPermission’ to execute this code • Seal your Web Part!

  17. ISecurableObject Interface • Everybody doing security implements this interface • SPWeb, SPList, SPListItem

  18. Example: DoesUserHavePermissions

  19. demo Better support for security and OM programming

  20. Querying Data with CAML • CAML = Collaborative Application Markup Language • Used in SharePoint for • Definition of the Sites, Lists and Views • Querying of SharePoint content • Executing CAML Queries • SPQuery • SPSiteDataQuery • Lists.asmx

  21. demo Executing CAML Queries

  22. WorkingRemotelywithLists and Documents Remotely view and edit SharePoint List data http://[server]/_vti_bin/Lists.asmx Operations available: Work with Document Libraries using FrontPage RPC

  23. demo An off-line client for a lists and document libraries in SharePoint

  24. WSS v2 vs. WSS v3 Event Handlers • What is an event handlers? • An event handler is a .NET assembly containing one or more classes handling events that are triggered by SharePoint • WSS v2 • only possible for document libraries • executed in an asynchronous manner • WSS v3 events architecture significantly improved • Scope has been extended: lists, document libraries, content types, site, site collection • Events supported for incoming email messages • Support for synchronous events and asynchronous events • Synchronous events occur before the fact and are cancel-able • Events are used in other scenarios • Custom policies • Features

  25. Scope of Events

  26. Creating an Event Handler • .NET class library • Reference to Microsoft.SharePoint.dll • Custom class inheriting a WSS receiver class • Override base methods using Microsoft.SharePoint; namespace Demos { public class MyEventHandler: SPItemEventReceiver { public override void ItemDeleting(SPItemEventProperties properties) { // do something and possibly cancel the event properties.Cancel = true; properties.ErrorMessage = “my message"; } public override void ItemDeleted(SPItemEventProperties properties) { // do something } } }

  27. Deploying a WSS v3 Event Handler • Compile class into strong-named assembly • Deploy the DLL in GAC • Register DLL as event handler in WSS v3 • The WSS v2 way (only for document libraries) • Programmatically via the object model • Using the new WSS feature framework

  28. demo WSS Event Handlers

  29. New Classes in WSS OM • Navigation • Content Types • Recycle Bin • Versioning • Workflow

  30. Navigation • WSS Navigation is extensible • Add nodes through WSS UI • Adds nodes through code

  31. Content Types • SPContentTypeCollection • SPContentType • SPContentTypeId • SPFieldLinkCollection • SPFieldLink • SPXmlDocumentCollection

  32. SPAudit and SPAuditEntry • WSS provides rich auditing support • But doesn't make auditing usable OOB - you need MOSS • Custom development required to make WSS auditing functional • enable auditing using code • now examine what's in WSS audit log

  33. demo New OM Classes

  34. Summary • WSS exposes a veryrichobject model • Don’tforget to clean up your WSS v2 code a bit • And do call Dispose() • Manyimprovements have been done to remove the many issues regardingsecurity and SharePoint programming • Impersonationis more elegant • Common interface for objectsthat support ACL’s • Web Services are yourway of gettingacces to SharePoint remotely • Event handlers are now a major extensibility option • Manymany new classes .. And wait ‘till you’veseen the MOSS objectmodels

  35. Q&A Questions?

  36. Related Content Breakout SessionsSession Codes and Titles • Chalk-TalksSession Codes and Titles • Instructor-led LabsSession Codes and Titles • Hands-on LabsHands-on Lab Codes and Titles

  37. Resources Required slide Technical Communities, Webcasts, Blogs, Chats & User Groups http://www.microsoft.com/communities/default.mspx Microsoft Learning and Certification http://www.microsoft.com/learning/default.mspx Microsoft Developer Network (MSDN) & TechNet http://microsoft.com/msdn http://microsoft.com/technet Trial Software and Virtual Labs http://www.microsoft.com/technet/downloads/trials/default.mspx

  38. Required slide Complete an evaluation on CommNet and enter to win!

More Related