My client application uses the SharePoint Client Object Model against SharePoint 2010 and 2013. I would now like to add support for SharePoint Online.

Users of my application specify the 'Url' to their SharePoint site and their credentials. Since connecting to SharePoint Online requires using the 'SharePointOnlineCredentials', I would like to guess which version of SharePoint is being targeted based on these values and then use the appropriate credentials type. Certain heuristics that I currently use

  1. If the username is of the form DOMAIN\username, I assume it to be targeting 2010/2013
  2. If username is not an email address I assume it to be targeting 2010/2013
  3. If either username or password is not specified then it's assumed to be targeting 2010/2013 using NetworkCredentials

    My question is - is there a fool proof way of guessing the version without trying to connect to the actual instance (which could result in exceptions)?

  • As part of the user interface you add a dropdown with the target values. Let the user select that also as part of entering the details. Oct 28, 2014 at 14:01
  • 1
    Of course I can do that as the last resort but wanted to know if there was a way to avoid doing that. Oct 28, 2014 at 15:05

1 Answer 1


Querying my work's SharePoints the response header has the SharePoint version.

I don't know how many SharePoints will have that available for you to check but you could try this before the failsafe of asking the user.

SharePoint 2010 SharePoint 2013

  • My O365 site currently gives a version of -- but I wonder if there could ever be a situatin where the version for O365 could be the same as an on prem environment
    – John-M
    Oct 28, 2014 at 16:05
  • Sorry but did not understand what I need to do exactly. How would that translate to C# code. Do I need to connect to the SharePoint site or call some service endpoint? Oct 28, 2014 at 16:16
  • @john The MVPs might know better if it's been decided if vNext will be 16 or 17 but I think only time will tell.
    – Choggo
    Oct 28, 2014 at 17:37
  • @alwayslearning By sending a request to the page, IIS will return those elements on the response header. You can use whichever language you are familiar with to see the result.
    – Choggo
    Oct 28, 2014 at 17:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.