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
- If the username is of the form DOMAIN\username, I assume it to be targeting 2010/2013
- If username is not an email address I assume it to be targeting 2010/2013
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)?