Using SharePoint API

The SharePoint API offers a great way to modifiy and create SharePoint content. You only need to be aware of the following restrictions:

  1. You need to run the code on the front-end server on which you want to use the API on. Otherwise use the SharePoint web services.
  2. The user executing the code must be be farm administrator.
  3. The user executing the code must have the following permissions on the database:
    1. Configuration database: Pulic, wss_content_application_pools
    2. Content database: db_owner
    3. Admin content database: Public

If this can be done there is nothing in the way using the SharePoint API. Remember to use the Dispose pattern for the SPSite and SPWeb objects.

To access a site you may use this code:

try {
   SPSite site = new SPSite("url");
   SPWeb web = site.OpenWeb();
finally {

Note: Never, ever dispose the SPContext.Current.Web.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.