Monday, March 30, 2009

SharePoint Object Model

The SharePoint object model has four top-level objects:

* SPWeb (represents an individual site).
* SPSite (represents a site collection, which is a set of web sites).
* SPVirtualServer (represents a virtual server).
* SPGlobalAdmin (used for global administration settings).

In order to perform actions on data within a web, it is necessary to first get an SPWeb object (e.g. SPWeb MyWeb = SPControl.GetContextWeb(Context);)

The complete object model is grouped into lists, files (documents), security and administration:

* Lists - use these objects under the Microsoft.SharePoint namespace to view and edit data in SharePoint lists:
o SPList (basic list object for getting to list data).
o SPListCollection (collection of list objects).
o SPListItem (item/row in a list).
o SPListItemCollection (collection of list items).
o SPView (view of a SharePoint list).
o SPField (field/column in a list).
o SPListTemplate (template for a list).
* Files - use these objects under the Microsoft.SharePoint namespace to access document files in SharePoint sites:
o SPFile (file object).
o SPFileCollection (collection of files).
o SPFileVersion (version of a file).
o SPFolder (folder object).
o SPDocumentLibrary (document library object).
o SPDocDiscussion (discussions on a file).
o SPDocTemplate (used when creating a new file).
* Security - use these objects under the Microsoft.SharePoint namespace to edit access rights and security information:
o SPUser (user object).
o SPRole (site group object).
o SPGroup (cross-site group object).
o SPPermission (assigned permissions).
o SPRightsEnumeration (available permissions).
* Administration - use these objects under the Microsoft.SharePoint.Administration namespace to edit server-wide administrative settings.
o SPGlobalAdmin (top level administration object).
o SPVirtualServer (virtual Server object).
o SPQuota (storage/user quota limit object).
o SPGlobalConfig (configuration options).
o SPSiteCollection (collection of sites on a virtual server).

In terms of mapping the user interface onto the object model terminology:

* Site Collection = site.
* Site = web.
* Top-level site = rootweb.
* Subsite = subweb.