My career in technology

When a user with contribute permissions tries to upload a .swf file to SharePoint 2010 library, they get the following error message after the upload appears to complete:

Error: Access Denied

There is a list of file types, including shockwave files, that users with Contribute permissions cannot submit to SharePoint libraries.  In order to be able to submit these files to libraries, the user has to have higher-level permissions (like Design).  But these files are not in the blocked file types list found in Central Administration (http://YourCentralAdminURL/_admin/BlockedFileType.aspx).  What gives?

I provide the answer and a PowerShell script to solve the problem.

According to this Microsoft KB article (2483447), there is a list of files that are blocked (at least partially) from being uploaded, but aren’t part of the BlockedFileExtensions.

  • ASPX
  • MASTER
  • XAP
  • SWF
  • JAR
  • ASMX
  • ASCX
  • XSN
  • XSF

Instead, these files are part of WebFileExtensions.  But unlike the BlockedFileExtensions, the WebFileExtensions list isn’t available in Central Administration to be managed.

Also unlike file types in BlockedFileExtensions, these files can be uploaded if the user has sufficient privileges, specifically the “Add and Customize Pages” permission.

In the use case we had, we didn’t want to give the user additional permissions, especially not the “Add and Customize Pages” permission, because the layout for this particular site was so specific.  The user was responsible for managing media and other content on the site, so they needed to be able to add .swf files as needed. 

In order to make this happen, the WebFileExtensions list needed to be modified.  According to the KB article, it has to be done programatically.  With SharePoint 2007, I would have had to write a console application. Not impossible, but a bit of a pain.  But not with SharePoint 2010.

“This is a job for PowerShell!”  I am just loving PowerShell.  (You are going to be seeing a lot of PowerShell scripts here at Working It Out).

Here is the script for modifying the list of WebFileExtensions (note that this list is per web application!):

$WebApp = Get-SPWebApplication http://YourSiteCollectionURL/
$Extensions = $WebApp.WebFileExtensions
$Ext = $Extensions.Remove("swf")
$WebApp.Update()

To find out what file extensions are listed in the WebFileExtensions of your collection, you can use this script:

$WebApp = Get-SPWebApplication https://YourSiteCollectionURL/
$Extensions = $WebApp.WebFileExtensions
$Extensions | ForEach-Object {Write-Host $_}

And if, for some reason, you want to add an extension to this restricted list (say, for instance only certain users should be able to upload media files like .mp3 or .avi), swap .Add() for .Remove() in the first script. And if you think you will be doing this kind of thing often, use the handy scripts to create cmdlets provided by SharePoint Ryan (and be sure to change BlockedFileExtensions to WebFileExtensions).

More posts about SharePoint.

Advertisements

Comments on: "Quick Fix: User With Contribute Permissions Can’t Upload .swf to SharePoint 2010?" (1)

  1. Thank you very much!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: