Managing External Sharing in SharePoint Online

A question I frequently hear from clients when moving to Office 365 and SharePoint online, is how can I manage external sharing?

Maybe an organization does not want to allow content to be shared with external users, or allow users direct access to documents without first having an account and logging in. There are many different situations and requirements which may need to have the external sharing settings tweaked.

To do so, go into your SharePoint Online Admin Center

image

and select Settings from the left-side navigation

image

And then once there (and currently it is the second header down on the right side of the screen), choose one of the options which firs your requirements.

  • Don’t allow sharing outside your organization
  • Allow external users who accept sharing invitations and sign in as authenticated users
  • Allow both external users who accept sharing invitations and anonymous guest links

image

Content Query Web Parts, Anonymous Access, and the Dreaded CopyUtil.aspx in SharePoint 2010

I spent some decent time over the past couple of days trying to get a Content Query Web Part in SharePoint 2010, that was aggregating blogs from several different sites to “just work”, and was not having any luck. Basically, the CopyUtil.aspx page, which resides in the SharePointRoot/TEMPLATE/LAYOUTS/ folder, redirects you based on the ListID, ItemID, and WebID of the target item within the Content Query Web Part.

This work is being done for a client, who is migrating their public website from SharePoint 2007 to SharePoint 2010. It’s been a great project for a great client, however, as with any project, there are always a few curveballs unique to that specific project. This was one of them.

In their prior version of the site, the previous developer implemented the solution which can be found here: http://www.sharepointforum.se/en-US/Bugday/Lists/Posts/Post.aspx?ID=9, a custom application page and a DLL to go with it. This did not work on my client’s 2010 environment, so I had to go looking elsewhere, and was not finding too much. My good friend, Christina Wheeler, happened to direct me to a blog post she did on the matter, which was a great idea, however, this one was also directed at 2007 – http://sharepoint.mindsharpblogs.com/ChristinaW/archive/2009/12/07/Content-Query-Web-Parts-and-Anonymous-Access.aspx, or at least, an environment that was not similar to my client. There was no dispform.aspx within the layouts folder, and dropping one copied out of a document library required a bit of toiling to work… and it would not reference the master page I was hoping to use.

All looked bleak and hopeless, however, the #2 method in Christina’s post was the ticket, and, I found the example code that I needed out on the interwebs as well! Hooray for the interwebs! Which led me to this blog post: http://www.sectorpoint.com/blog/post/2008/07/10/Anonymous-access-and-the-Content-by-Query-Web-Part-(CQWP).aspx

Now, the version there however, is for 2007 as well, but, looking at how they did it, made perfect sense, and I was able to put it to practice in SharePoint 2010.

Here are the steps to get this functional…

Go into the SharePointRoot/TEMPLATE/LAYOUTS/ folder –

NOTE: DO NOT DO ANYTHING TO THE ORIGINAL COPYUTIL.ASPX!

And, create a new file, for example, GVCopyUtil.aspx, and put the following code into it, the only change from CopyUtil.aspx, is the line highlighted below.

<%@ Assembly Name=”Microsoft.SharePoint.ApplicationPages, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”%>
<%@ Page Language=”C#” CodeFile=”CopyUtil.aspx.cs” Inherits=”CopyUtil” MasterPageFile=”~/_layouts/application.master” %>
<%@ Import Namespace=”Microsoft.SharePoint.ApplicationPages” %>
<%@ Register Tagprefix=”SharePoint” Namespace=”Microsoft.SharePoint.WebControls” Assembly=”Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
<%@ Register Tagprefix=”Utilities” Namespace=”Microsoft.SharePoint.Utilities” Assembly=”Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
<%@ Import Namespace=”Microsoft.SharePoint” %>
<%@ Assembly Name=”Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
<%@ Register TagPrefix=”wssuc” TagName=”TopNavBar” src=”~/_controltemplates/TopNavBar.ascx” %>
<%@ Register TagPrefix=”wssuc” TagName=”LinksTable” src=”/_controltemplates/LinksTable.ascx” %>
<%@ Register TagPrefix=”wssuc” TagName=”InputFormSection” src=”/_controltemplates/InputFormSection.ascx” %>
<%@ Register TagPrefix=”wssuc” TagName=”InputFormControl” src=”/_controltemplates/InputFormControl.ascx” %>
<%@ Register TagPrefix=”wssuc” TagName=”LinkSection” src=”/_controltemplates/LinkSection.ascx” %>
<%@ Register TagPrefix=”wssuc” TagName=”ButtonSection” src=”/_controltemplates/ButtonSection.ascx” %>
<%@ Register TagPrefix=”wssuc” TagName=”ActionBar” src=”/_controltemplates/ActionBar.ascx” %>
<%@ Register TagPrefix=”wssuc” TagName=”ToolBar” src=”/_controltemplates/ToolBar.ascx” %>
<%@ Register TagPrefix=”wssuc” TagName=”ToolBarButton” src=”/_controltemplates/ToolBarButton.ascx” %>
<%@ Register TagPrefix=”wssuc” TagName=”Welcome” src=”/_controltemplates/Welcome.ascx” %>
<%@ Register Tagprefix=”wssawc” Namespace=”Microsoft.SharePoint.WebControls” Assembly=”Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
<%@ Register Tagprefix=”SharePoint” Namespace=”Microsoft.SharePoint.WebControls” Assembly=”Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
<asp:Content ID=”Content1″ ContentPlaceHolderId=”PlaceHolderPageTitle” runat=”server”></asp:Content>

Now, save that, and create another file in the folder, called CopyUtil.aspx.cs, and paste the following C# code into that:

using Microsoft.SharePoint.ApplicationPages;

public partial class CopyUtil : Microsoft.SharePoint.ApplicationPages.CopyUtil
{
protected override bool AllowAnonymousAccess
{
get
{
return true;
}
}
}

Not so hard, huh? And actually, it is pretty simple, even if you are a non-developer, so don’t be scared. The first section, and more importantly, the highlighted section, says that the language of the page is C# – a programming language. CodeFile references the code it will use. Inherits, means that the page will utilize the class CopyUtil from the CodeFile mentioned previously. And the master page directive just states that we will use that as our master page.

How did we figure out the class to use? Easy, that is highlighted in the 2nd code snippet above.

Now for the second code snippet, all this does, is make use of the Microsoft.SharePoint.ApplicationPages namespace – found on the first line with “using”. We are then inheriting all of the code that makes up this page, and then overriding the boolean value for AllowAnonymousAccess, and setting that to TRUE, rather than it’s normal value, which is FALSE.

In any event, Christina really saved my tuckus today – so thank you Christina!

%d bloggers like this: