Tag Archives: Microsoft SharePoint

SharePoint Online AppRegNew via PowerShell

$clientId = "clientId GUID"
$appDomain = "App Domain"
$appName = "Friendly Name"
$appUrl = "App Url"
$newClientSecret = "Client Secret"

$servicePrincipalName = @("$clientID/$appDomain")
New-MsolServicePrincipal -ServicePrincipalNames $servicePrincipalName -AppPrincipalId $clientID -DisplayName $appName `
  -Type Symmetric -Usage Verify -StartDate "12/01/2016" -EndDate "12/01/2017" -Addresses (New-MsolServicePrincipalAddresses -Address $appUrl) 
New-MsolServicePrincipalCredential -AppPrincipalId $clientId -Type Symmetric -Usage Sign -Value $newClientSecret
New-MsolServicePrincipalCredential -AppPrincipalId $clientId -Type Symmetric -Usage Verify -Value $newClientSecret
New-MsolServicePrincipalCredential -AppPrincipalId $clientId -Type Password -Usage Verify -Value $newClientSecret

SharePoint 2013 MCSD Beta MCSD Exams

I just signed up for the new SharePoint 2013 MCSD Beta exams 71-488 and 71-489. I managed to snag registration of these exams for free, with some promotions codes floating around the Internet.
Vlad has the codes posted on his blog – if you try them you migth be lucky to register for free, otherwise, the exams cost $150 a peice.

Unfortunately, there’s not a ton of material out there for study as yet (plug my book), as you’d expect with the exams in Beta.
Some of the topics in the beta exams require development skills and knowledge of Visual Studio. Vlad has included a summary of the study topics at the following locations:

Developing Microsoft SharePoint 2013 Core Solutions (71-488).
Developing Microsoft Sharepoint 2013 Advanced Solutions (71-489).

For those of you wondering the difference between 70-488 & 71-488; and 70-489 & 71-489…
Microsoft uses 71-xxx for Beta exams. Release of the official exam is scheduled for June and will use the 70-488 and 70-489 numbers.

If you pass the beta exams now, you won’t have to retake the official release versions after June.

Incase Vlad changes his blog, and for my study reference, the following is a list of the topics measured in each exam. Also check out these handy PDF (fillable) checklists I created…

70-488 Checklist
70-489 Checklist

71-488/70-488 – Skills Measured
Plan and Design SharePoint Sites (10-15 percent)
  • Manage the site life cycle.
    • This objective may include but is not limited to: create a delayed site collection, manage site collection disposition, identify inactive site collections, back up and archive site collection data
  • Create content types.
    • This objective may include but is not limited to: subscribe to published content types, choose appropriate content type creation, use Schema Development, create content types using Object Model, create site columns, use content type inheritance
  • Manage content type behaviors.
    • This objective may include but is not limited to: manage event receivers, manage workflow associations, manage policies, manage document templates
  • Implement site provisioning.
    • This objective may include but is not limited to: create site definitions, create web templates, implement feature stapling, implement custom provisioning code
Implement Authorization and Authentication (10-15 percent)
  • Implement user authentication.
    • This objective may include but is not limited to: create a custom claims provider, create a custom sign-in page, create a custom membership provider, package and deploy a custom claims provider, package and deploy a custom membership provider, authenticate a user from a client application
  • Implement application authentication and authorization.
    • This objective may include but is not limited to: use the SharePoint App TokenHelper class, specify the App permission request scope manifest and permission request manifest, specify permissions for Office Store Apps, specify permissions for Corporate Catalog Apps, specify permissions for remote apps to access SharePoint data
  • Plan and implement user authorization.
    • This objective may include but is not limited to: create custom role definitions, create custom permission levels, maintain permissions, implement impersonation, plan and implement anonymous access, create a custom role manager
Access and Manage Data (10-15 percent)
  • Design solutions to handle large amounts of data.
    • This objective may include but is not limited to: create efficient CAML queries and views, choose appropriate APIs, create and use indexed columns, use Object Model Overrides, use Content Iterator, implement cross-site queries
  • Access data contained in SharePoint.
    • This objective may include but is not limited to: access data using server-side object model, access data using client-side object model (CSOM), access data using REST API, access data using out-of-the-box Web Services, access data using a custom WCF (Windows Communication Foundation) service to facilitate integration with an existing application
  • Store configuration data.
    • This objective may include but is not limited to: implement a hierarchical data store, implement a property bag, implement web.config, implement SharePoint List, implement credential storage
Implement SharePoint Solutions (15-20 percent)
  • Manage SharePoint Object Life Cycle.
    • This objective may include but is not limited to: implement Object Life Cycle management for SPWeb, implement Object Life Cycle management for SPSite, implement Object Life Cycle management for other objects, implement Object Life Cycle management with Windows PowerShell, implement Object Life Cycle management for SPContext
  • Upgrade solutions and features.
    • This objective may include but is not limited to: implement versioning of features and solutions, upgrade features and solutions, implement assembly versioning, build components for in-process request routing
  • Determine a solution structure.
    • This objective may include but is not limited to: select feature scope and visibility, define feature dependencies, define solution dependencies, organize SharePoint project items, structure app packages
  • Create sandbox solutions.
    • This objective may include but is not limited to: scope features to constraints, identify SharePoint artifacts that can be used in sandbox, access data outside of Sandbox scope, configure and troubleshoot sandbox solution deployment, upgrade sandbox solutions, implement solutions validators
  • Create a no-code solution.
    • This objective may include but is not limited to: configure no-code customizations for the SharePoint 2013 platform, create XSLT for web parts, create and upload JavaScript files, create Display Templates
Implement the User Experience and Information Architecture (10-15 percent)
  • Implement branding.
    • This objective may include but is not limited to: incorporate designer outputs, use Design Manager functionality, apply custom themes, export the design, create Master Page, create a channel
  • Implement navigation.
    • This objective may include but is not limited to: create a custom navigation provider, create taxonomy-based navigation, create search-driven navigation, configure globalcurrent navigation
  • Customize UI elements.
    • This objective may include but is not limited to: customize the ribbon, customize the edit control block (ECB), customize the status bar and notifications, customize the modal dialog window, customize the upgrade notification, select areas for Focus on Content
Create Business Processes (10-15 percent)
  • Create event receivers and timer jobs.
    • This objective may include but is not limited to: plan the use of event receivers or timer jobs, create remote event receivers, create a work item timer job
  • Create SharePoint Designer workflows.
    • This objective may include but is not limited to: plan the type of workflow and associated forms (site, reusable, list, InfoPath), use custom actions, create workflow definition, create reusable workflows for content types, import and export Microsoft Visio workflows, export a workflow to a SharePoint solution
  • Create and deploy Microsoft Visual Studio workflows.
    • This objective may include but is not limited to: create custom actions, create a workflow definition, create external connectors, deploy a workflow as part of a SharePoint solution or app, upgrade a SharePoint 2013 Visual Studio workflow, plan the type of workflow and associated forms
Create Office Apps (10-15 percent)
  • Plan and design applications.
    • This objective may include but is not limited to: choose a hosting location, specify a starting location, specify a licensing model, specify permission requirements, select a user experience for apps
  • Create applications.
    • This objective may include but is not limited to: create provider-hosted applications, create auto-hosted applications, create SharePoint-hosted applications, apply chrome control
  • Package and deploy Apps.
    • This objective may include but is not limited to: package an application, publish to Corporate Catalog, publish to SharePoint store, publish to Windows Azure, manage trust relationship with other providers
  • Manage the App life cycle.
    • This objective may include but is not limited to: upgrade an application, remove an application, manage licensing, manage usage tracking
71-489/70-489 – Skills Measured
Design and Implement Search (15-20 percent)
  • Query Search.
    • This objective may include but is not limited to: build search queries using FQL (FAST Query Language) and KQL (Keyword Query Language), execute search queries using client-side object model (CSOM), Web Services, and REST
  • Customize search results.
    • This objective may include but is not limited to: create custom result sources, create display templates, create result types, create custom refiner definitions, implement query rules
  • Customize content processing.
    • This objective may include but is not limited to: feed external content types, implement content processing extensions (entity extraction), configure out-of-the box content processing, create content mappings
Implement  BCS (Business Connectivity Services) (10-15 percent)
  • Create a model.
    • This objective may include but is not limited to: optimize queries for performance and throttling, use naming conventions, use batching, create filters, implement methods, create associations
  • Create external content types.
    • This objective may include but is not limited to: use SQL data sources, use WCF (Windows Communication Foundation) Web Services, use oData, use.NET connector
  • Implement authorization and authentication.
    • This objective may include but is not limited to: use pass-through, use BCS Identity and User Identity, use a custom model
  • Create custom connectors.
    • This objective may include but is not limited to: implement methods (including Search), implement security trimming, implement configuration properties, implement caching, implement external event receiver
  • Access BCS data.
    • This objective may include but is not limited to: use BCS Web Parts, use BCS data in workflows, use BCS CSOM, use the server-side object model, use BCS REST
  • Implement client-side BCS.
    • This objective may include but is not limited to: use caching, use Microsoft Office apps, use Microsoft Visual Studio Tools for Office, use SQL replication, implement authorization and authentication
Implement User Profiles and Customize Social Workload (15-20 percent)
  • Manage user profile properties.
    • This objective may include but is not limited to: create and update user profile properties, update privacy filters, map properties to external data, use managed metadata term sets, update profile picture
  • Manage feeds.
    • This objective may include but is not limited to: use CSOM to follow documents, people, sites, get feeds, create posts, and manage Like, reply, mention, tag, link, add pictures
  • Access user profile data.
    • This objective may include but is not limited to: use CSOM, use the object model, use REST, use Web Services
Implement ECM (Enterprise Content Management) and WCM (Web Content Management) (15-20 percent)
  • Implement a multi-lingual site.
    • This objective may include but is not limited to: submit a page or batch of pages for translation, publish pages, create source and target labels, create channels, implement multi-language site navigation
  • Implement E-discovery.
    • This objective may include but is not limited to: create a new hold, integrate with Microsoft Exchange Web Services, specify content sources and Search criteria, export discovery sets, manage permissions for hold
  • Implement SEO (Search Engine Optimization).
    • This objective may include but is not limited to: create a site map, customize a site map, maintain SEO configuration properties, maintain robots.txt file, maintain SEO properties on term, learn more of SEO case studies
  • Implement content management.
    • This objective may include but is not limited to: create information management policies, create content organizer rules, create document sets, create document ID providers
  • Implement a publishing page.
    • This objective may include but is not limited to: add field controls to a page layout, add web parts to a page layout, create a publishing page layout, inherit content types
Design for Performance and Troubleshooting (15-20 percent)
  • Design solutions to handle a high-traffic site.
    • This objective may include but is not limited to: combine images, implement caching, minimize number of queries, optimize JavaScript loading, use CDNs (Content Delivery Networks), create a scalable aggregator
  • Design client applications for performance.
    • This objective may include but is not limited to: leverage health score rules, optimize number of batch server requests, use client-side cache, minimize amount of data requested
  • Monitor and mitigate performance and scalability issues.
    • This objective may include but is not limited to: diagnose application stability issues, debug the server side and app code on the client side, create application diagnostics, measure and test application performance
Implement Managed Metadata Service (MMS) (15-20 percent)
  • Manage term sets.
    • This objective may include but is not limited to: import and export term sets, create multi-lingual labels, re-use terms, manage term properties, perform translation, create groups and assign permissions
  • Create solutions by using MMS.
    • This objective may include but is not limited to: use Profile Pages, use the Product Catalog, use cross-site publishing, integrate with Search, implement metadata-driven navigation
  • Use an MMS API.
    • This objective may include but is not limited to: use CSOM in client applications, use REST in client applications, use managed fields, use server-side object model

SharePoint 2013 Managed Navigation

After much awaited anticipation, SharePoint 2013 now offers custom navigation of sites via the Managed Metadata Term Store. SharePoint 2010 introduced managed metadata for tagging purposes, with hierarchical terms. This same hierarchical infrastructure bodes well for site navigation, which is also hierarchical. I often hear the word “taxonomy” said a lot, pertaining to both tagging taxonomy and site structure, which just speaks to the fact that the Managed Metadata Term Store is great for managing custom navigation.

Prior to SharePoint 2013, custom navigation typically involved some custom component, to read navigation structure from either a list, XML file, or some other hierarchical node store. The out-of-the-box offering provided very little in the way of custom navigation – just the ability to include headers and links at each site level. The main issue with the out-of-the-box offering is that it was limited in the number of nested navigation nodes, without adhering to the actual structure of sites and sub-sites in the collection. Despite typical site navigation following site structure, content owners should have the ability to store their content (sites and pages) in any structure and the navigation look completely different. Content storage and structure suits how content owners maintain content, and navigation is about how end users access content, and the two may look very different. Managed Metadata Navigation finally allows content owners to create an independent navigation structure to that of their content model.

To demonstrate Managed Navigation, I shall first create a hierarchy in the default term store, for our application:

  1. Open Central Administration
  2. Click the link for managed service applications
  3. Scroll down the list and click the Managed Metadata Service
  4. Click the Manage icon in the ribbon to open the Term Store editor
  5. Ensure you have permissions to edit the term store – add your username to the term store administrators field
  6. Managed navigation binds to term sets, so I created a new group for navigation and then a term set for site navigation

SharePoint creates a default term set in the Managed Metadata Term Store for your site collection; I created my own for demonstration purposes.

  1. Create a term set structure
  2. Click the Site Navigation term set
  3. In the right panel, click the tab for Intended Use
  4. Check the checkbox to enable the term set for navigation – you can also use the term set for tagging if you wish by toggling the other checkbox option
  5. Click the save button to save the changes
  6. Click the tab for term driven pages – this page shows the settings for friendly URLs for the term set (more on friendly URLs shortly)
  7. Now we are ready to configure our publishing site to use the managed navigation
  8. Open your publishing site (assuming the hosting web application uses the managed metadata service you just configured)
  9. Click the gear icon, the select the menu item for site settings
  10. Click the link for Navigation, under the Look and Feel header
  11. SharePoint displays the navigation settings page
  12. Choose the radio button option for Managed Navigation for either or both the left and global (top) navigation
  13. Scroll to the bottom of the page to the managed navigation term set section
  14. Select the term set to use for managed navigation
  15. The checkboxes below the term set browser tell SharePoint whether to populate your term set with nodes when you create new pages in the site, and whether to generate friendly URLs for new pages
  16. Click the OK button at the bottom of the page, to save your changes


How to change a Page Layout Associated Content Type Id Programmatically

I developed some code that uploads a new page layout file (ASPX) from disk to the Master Page Gallery of a site collection.  I wanted to associate the uploaded publishing page with an existing content type, such as the “Welcome Page” content type.  This is equivalent to editing the properties of the page layout and setting the “Associated Content Type” property…




Setting the Associated Content Type property in code is not as easy as thought.  After trawling around the web for an hour, I found no good example.  I found plenty of examples to create a Page Layout declaratively in XML and assign the associated content property, but no examples in C# for an existing SPFile object.  Then it hit me…

The PublishingAssociatedContentType property expects a formatted string that contains both the display name and the content type ID.  So, armed with both an SPFile object that is the page layout file and an SPContentType object, I was able to associate the page layout with the following code:

file.Item.Properties["PublishingAssociatedContentType"] = String.Format(";#{0};#{1};#", spCT.Name, spCT.Id.ToString());

Make sure to call file.Item.Update();


Site Collection Restore Error

If you ever run into the following error when performing a site collection restore, via STSADM, and you know space is not an issue, try the steps below before diving deep into troubleshooting mode:

The site collection could not be restored. If this problem persists, please make sure the content databases are available and have sufficient free space.

  • Stop and start the SharePoint Timer Service
  • Restore to a new content database

Top SharePoint

Check out http://www.topsharepoint.com for the latest and greatest list of sites implemented on the SharePoint platform. 

A number of the sites listed were implemented by my current employer – Portal Solutions – who are also listed because our site is hosted in SharePoint.  A couple of the sites were managed and architected by yours truly 🙂

“TopSharepoint.com showcases some of the world’s best designed SharePoint based web sites from around the world. We carefully select SharePoint web sites based on their usability, design, creativity and ability to incorporate modern techniques. Anyone can submit a SharePoint web site for free and the only requirements we ask for is that your web site is built on SharePoint platform, well designed and original. So, if you developed, or found a SharePoint web site that might meet the above requirements we want to know about it! Please go ahead and submit your website to the TopSharepoint showcase gallery.”

Here’s my offspring, listed in the top 5:


Efficient way to add a new item to a SharePoint list

Never use SPList.Items.Add because this approach gets all items in the list before adding a new SPListItem.  Use the following method instead, which does not preload the list items:

   1:  /// <summary>
   2:          /// More efficient way of adding an item to a list.
   3:          /// </summary>
   4:          /// <remarks>
   5:          /// GetItems with a query is faster than calling the OM to get all items.
   6:          /// This is because the SPListItemCollection is created without loading all the
   7:          /// data until the first query request.  Whereas SPList.Items loads all the data
   8:          /// at construction.
   9:          /// </remarks>
  10:          /// <param name="list">List.</param>
  11:          /// <returns>List Item Added.</returns>
  12:          public static SPListItem OptimizedAddItem(SPList list)
  13:          {
  14:              const string EmptyQuery = "0";
  15:              SPQuery q = new SPQuery {Query = EmptyQuery};
  16:              return list.GetItems(q).Add();
  17:          }

SharePoint Development Best Practices (Summary)

I’ve read several blog posts of late regarding best practices for developing SharePoint API based components.  Some developers are aware of issues surrounding disposal of SPSite and SPWeb objects and the use of SPList Item collections, and some are not.  The simple fact is the SharePoint API is not intuitive when it comes usage of memory hungry-object instances, and it is all too easy to leave too many of these objects in memory for the garbage collector to deal with – causing large memory spikes in the site application pool with high traffic utilization.  Furthermore, what seems like innocent well structured code can perform badly because of the underlying calls against the SharePoint content databases.  This blog post serves as a reference point and as a quick summary of some of the best practices.

Best Practices: Using Disposable Windows SharePoint Services Objects


Enable the following registry setting to populate the ULS logs with allocation identifiers to isolate non-disposed SPSite and SPWeb objects:
HKEY_LOCAL_MACHINESOFTWAREMicrosoftShared ToolsWeb Server ExtensionsHeapSettings SPRequestStackTrace = 1

Wrap all calls that create a new SPSite or SPWeb object (except those from obtained from the SPContext.Current singleton) in try, catch, finally blocks, or using statements

SPContext objects are managed by the SharePoint framework and should not be explicitly disposed in your code. This is true also for the SPSite and SPWeb objects returned by SPContext.Site, SPContext.Current.Site, SPContext.Web, and SPContext.Current.Web.

You must be cautious and aware of what the runtime is doing whenever you combine SharePoint object model calls on the same line. Leaks arising from this scenario are among the hardest to find.

The finally block executes after calls to Response.Redirect in the try block. Response.Redirect ultimately generates a ThreadAbortException. When this exception is raised, the runtime executes all finally blocks before ending the thread. However, because the finally block can do an unbounded computation or cancel the ThreadAbortException, there is no guarantee that the thread will end. Therefore, before any redirection or transfer of processing can occur, you must dispose of the objects. If your code must redirect, implement it in a way similar to the following code example.

String str;
SPSite oSPSite = null;
SPWeb oSPWeb = null;

oSPSite = new SPSite("http://server");
oSPWeb = oSPSite.OpenWeb(..);

str = oSPWeb.Title;
if (oSPWeb != null)

if (oSPSite != null)

catch(Exception e)
if (oSPWeb != null)

if (oSPSite != null)


Good practices to reduce object long-term retention:

  • If you create the object with a new operator, ensure that the creating application disposes of it.
  • Dispose of items created by SharePoint methods that return other SPWeb objects (such as OpenWeb).
  • Do not share any SPRequest object (and by extension any object that contains a reference to an SPRequest object) across threads.

SPSite Object:

  • The SPSiteCollection.Add method creates and returns a new SPSite object. You should dispose of any SPSite object returned from the SPSiteCollection.Add method.
  • The SPSiteCollection [] index operator returns a new SPSite object for each access. An SPSite instance is created even if that object was already accessed. The following code samples demonstrate improper disposal of the SPSite object.
  • The SPSite.AllWebs.Add method creates and returns an SPWeb object. You should dispose of any SPWeb object returned from SPSite.AllWebs.Add.
  • The SPWebCollection.Add method creates and returns an SPWeb object that needs to be disposed.
  • The SPSite.AllWebs [] index operator returns a new SPWeb instance each time it is accessed.
  • The OpenWeb method and SelfServiceCreateSite method (all signatures) create an SPWeb object and return it to the caller.
  • The Microsoft.Office.Server.UserProfiles.PersonalSite returns an SPSite object that must be disposed.
SPSite.RootWeb Property

An earlier version of this article indicated that the calling application should dispose of the SPSite.RootWeb property just before disposing of the SPSite object that is using it. This is no longer the official guidance. The dispose cleanup is handled automatically by the SharePoint framework. Additionally, SPSite properties LockIssue, Owner, and SecondaryContact used the RootWeb property internally. Given the updated guidance for RootWeb, it is no longer advisable to call the Dispose method on the SPSite.RootWeb property whenever any of these properties are used.

SPWeb Object:

  • The SPWeb.Webs property returns an SPWebCollection object. The SPWeb objects in this collection must be disposed.
  • The SPWeb.Webs.Add method (or Add) creates and returns a new SPWeb object. You should dispose of any SPWeb object returned from this method call.
  • The SPWeb.Webs[] index operator returns a new SPWeb object for each access
SPWeb.ParentWeb Property

Updated Guidance

An earlier version of this article recommended that the calling application should dispose of the SPWeb.ParentWeb. This is no longer the official guidance. The dispose cleanup is handled automatically by the SharePoint framework.

Other Objects:

  • Microsoft.SharePoint.Portal.SiteData.Area.Web Property.  The Web property returns a new SPWeb object each time it is accessed.
  • If the object is obtained from the SharePoint context objects (GetContextSite method and GetContextWeb method), the calling application should not call the Dispose method on the object.
  • The SPLimitedWebPartManager class contains a reference to an internal SPWeb object that must be disposed.
  • The GetPublishingWebs method of the PublishingWeb class returns a PublishingWebCollection object. You must call the Close method on each enumerated innerPubWeb object. When you are calling only the GetPublishingWeb method, you are not required to call Close.
  • The Microsoft.SharePoint.Publishing.PublishingWeb.GetVariation method returns a PublishingWeb object that must be disposed.

Best Practices: Common Coding Issues When Using the SharePoint Object Model


Caching Data and Objects

Many developers use the Microsoft .NET Framework caching objects (for example, System.Web.Caching.Cache) to help take better advantage of memory and increase overall system performance. But many objects are not "thread safe" and caching those objects can cause applications to fail and unexpected or unrelated user errors.

Caching SharePoint Objects That Are Not Thread Safe

You might try to increase performance and memory usage by caching SPListItemCollection objects that are returned from queries. In general, this is a good practice; however, the SPListItemCollection object contains an embedded SPWeb object that is not thread safe and should not be cached.

You can cache a DataTable object that is created from the SPListItemCollection object.

Using Objects in Event Receivers

Do not instantiate SPWeb, SPSite, SPList, or SPListItem objects within an event receiver. Event receivers that instantiate SPSite, SPWeb, SPList, or SPListItem objects instead of using the instances passed via the event properties can cause the following problems:

  • They incur significant additional roundtrips to the database. (One write operation can result in up to five additional roundtrips in each event receiver.)
  • Calling the Update method on these instances can cause subsequent Update calls in other registered event receivers to fail.

Working with Folders and Lists

Do not use SPList.Items.  SPList.Items selects all items from all subfolders, including all fields in the list.

  • Instead of calling SPList.Items.Add, simply use SPList.AddItem.
  • Retrieve list items using SPList.GetItems(SPQuery query)
  • Instead of using SPList.Items.GetItemById, use SPList.GetItemById(int id, string field1, params string[] fields)

Do not enumerate entire SPList.Items collections or SPFolder.Files collections.

Poor Performing Methods and Properties Better Performing Alternatives
SPList.Items.Count SPList.ItemCount
SPList.Items.XmlDataSchema Create an SPQuery object to retrieve items you want
SPList.Items.NumberOfFields Create an SPQuery object (specifying the ViewFields)
SPList.Items[System.Guid] SPList.GetItemByUniqueId(System.Guid)
SPList.Items[System.Int32] SPList.GetItemById(System.Int32)
SPList.Items.ReorderItems Perform a non-paged query using SPQuery in each page
SPList.Items.GetItemById(System.Int32) SPList.GetItemById(System.Int32)
SPFolder.Files.Count SPFolder.ItemCount

Use PortalSiteMapProvider (Microsoft Office SharePoint Server 2007 only).

Steve Peschka's white paper Working with Large Lists in Office SharePoint Server 2007 describes an efficient approach to retrieving list data in Office SharePoint Server 2007 by using the PortalSiteMapProvider class.

(Very important as this works around the 2000 item limit)

Scaling Code

How to make this code more scalable or fine-tune it for a multiple user environment can be a hard question to answer. It depends on what the application is designed to do.

You should take the following into consideration when asking how to make code more scalable:

  • Is the data static (seldom changes), somewhat static (changes occasionally), or dynamic (changes constantly)?

  • Is the data the same for all users, or does it change? For example, does it change depending on the user who is logged on, the part of the site being accessed, or the time of year (seasonal information)?

  • Is the data easily accessible or does it require a long time to return the data? For example, is it returning from a long-running database query or from remote databases that can have some network latency in the data transfers?

  • Is the data public or does it require a higher level of security?

  • What is the size of the data?

  • Is the SharePoint site on a single server or on a server farm?

Using SPQuery Objects

SPQuery objects can cause performance problems whenever they return large result sets. The following suggestions will help you optimize your code so that performance will not suffer greatly whenever your searches return large numbers of items.

  • Do not use an unbounded SPQuery object.
  • An SPQuery object without a value for RowLimit will perform poorly and fail on large lists. Specify a RowLimit between 1 and 2000 and, if necessary, page through the list.
  • Use indexed fields.
  • If you query on a field that is not indexed, the query will be blocked whenever it would result in a scan of more items than the query threshold (as soon as there are more items in the list than are specified in the query threshold). Set SPQuery.RowLimit to a value that is less than the query threshold.
  • If you know the URL of your list item and want to query by FileRef, use SPWeb.GetListItem(string strUrl, string field1, params string[] fields) instead.

Authentication failed because the remote party has closed the transport stream

If you receiver the error "Authentication failed because the remote party has closed the transport stream" when accessing "Search Settings" in the SSP, the following steps will resolve the issue.  The issue is a result of incorrect self-serving-certificate.

1. Install the IIS 6.0 Resource Kit on the index server (http://www.microsoft.com/downloads/details.aspx?FamilyID=56fc92ee-a71a-4c73-b628-ade629c89499&DisplayLang=en)
2. Assign a new SSL certificate  to the Office SharePoint Server Web Services site on the index server using the SELFSSL tool from the resource kit.

SELFSSL.EXE /N:CN=<name of index server> /K:1024 /V:<number of days cert should be valid> /S:951338967  /P:56738
The /S and /P parameters specify the web site ID and port number, respectively, of the Office SharePoint Server Web Services site in IIS. They should be set to the appropriate values for your environment.