29 July 2012

SharePoint 2013 Explorer

UPDATE: Newer version of the tool now available here.



Here is one of the first developer utilities specifically built for SharePoint 2013. It will let you peek and poke at the internals of your SharePoint 2013 site collections, either on-premises or in the cloud.

The tool is based on SharePoint Explorer 365, read this post for the full details of its origin, capabilities and usage instructions. The changes in this new version are as follows:

  • Updated passive authentication code for Office 365 Preview as detailed in this post.
  • Compiled against SharePoint 2013 versions of Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.Client.Runtime.dll, which provide a range of additional objects, properties and methods compared to the 2010 versions (see below screenshots).
    Because of this, this version of the tool will not work against SharePoint 2010 site collections.
  • Compiled against the .NET Framework 4.0, so this needs to be installed if you want to run the tool.

Here is the download, read my previous post on SharePoint Explorer 365 regarding disclaimers and such.

You can see the expanded capacity of the 2013 version of the Client Object Model by comparing screenshots of the tool compiled with 2013 assemblies with screenshots of the same tool compiled with the 2010 assemblies.

Site Collection objects and properties in 2010 Client OM assemblies

Site Collection objects and properties in 2013 Client OM assemblies

Methods available against the Site Collection in 2010 assemblies

Methods available against the Site Collection in 2013 assemblies
This expansion of Client OM capabilities in SharePoint 2013 is great news, especially for Office 365 developers. The screenshots above relate to site collections, but there are new capabilities for webs, lists, and other SharePoint objects as well. This tool, or a .NET reflection tool, provides great insights into these new capabilities.

Note that SharePoint 2013 is in Preview and is liable to change as it matures (this is especially true of the Online version), so the tool may stop working at any time. In the meantime, have fun with it!

Thanks again to Stefan Stanev for building such an easily extendible SharePoint utility and providing the source code to the SharePoint community!

How to Passively authenticate into SharePoint 2013 Online using the .NET Client OM

In my last post I mentioned that the Passive authentication method for the .NET Client Object Model into SharePoint Online (Office 365) as outlined in this MSDN code sample is not compatible with SharePoint Online Wave 15 preview.

It turns out that there is a slight difference in the HTTP responses returned by the Wave 15 version of SharePoint Online compared with the 2010 version. Some of the URLs returned appear in triplicate, separated by commas. Discarding the multiple copies of the URLs brings the code back into working order.

The MSDN sample code can work in the new version of SharePoint Online, once you edit the ExtraHeadersFromResponse method in the ClaimsWebAuth class like so:

        private bool ExtraHeadersFromResponse(WebResponse response, out string loginUrl, out Uri navigationEndUrl)
        {
            loginUrl = null;
            navigationEndUrl = null;

            try
            {
                // For some reason, SharePoint Online Wave 15 Preview seems to return these responses in triplicate, separated by commas
                // Let's just get the first one

                string returnUrl = response.Headers[Constants.CLAIM_HEADER_RETURN_URL];
                if (returnUrl != null && returnUrl.Contains(","))
                {
                    returnUrl = returnUrl.Substring(0, returnUrl.IndexOf(",", StringComparison.InvariantCultureIgnoreCase));
                }
                navigationEndUrl = new Uri(returnUrl);

                loginUrl = (response.Headers[Constants.CLAIM_HEADER_AUTH_REQUIRED]);
                if (loginUrl != null && loginUrl.Contains(","))
                {
                    loginUrl = loginUrl.Substring(0, loginUrl.IndexOf(",", StringComparison.InvariantCultureIgnoreCase));
                }

                return true;
            }
            catch
            {
                return false;
            }
        }
Once this change is made, the code works in both the current and the next versions of SharePoint Online.

26 July 2012

SharePoint Online 2013 Preview: Programmatic Authentication

UPDATE: There is a solution to this issue described below, see this post.

As I'm sure you're all aware, SharePoint 2013 Preview (a.k.a. Wave 15) is now upon us!

I thought it would be a great time to confirm programmatic authentication into SharePoint Online, based on the Passive and Active authentication methods we have come to rely upon in the current 2010 based release of SharePoint Online (a component of Office 365).

The Passive technique requires the user running the code to interactively log in (or to have authenticated within the last 8 hours and still have an unexpired cookie available). This method is outlined here on MSDN and this was the basis of the SharePoint Online capable version of SharePoint Explorer.

Unfortunately this authentication method doesn't appear to work against the new version of SharePoint Online from my initial testing. Once the user is authenticated, the WebBrowser window that is created as part of the process looks like this:

What is interesting is that clicking the "GO BACK TO SITE" link (what's with the sudden Microsoft Metro obsession with ALL-CAPS?) actually brings up the SharePoint Preview site in the temporary WebBrowser object window. This makes me think that the approach can potentially work with a bit of Fiddling (pun intended)...

The Active authentication method described here appears to work just fine, thanks Wictor!

Note that you can create your own Preview tenancy of the upcoming version of SharePoint Online here. You need to go with an Enterprise tenancy as the other options won't grant you SharePoint Online. Have fun with it!