Tag Archives: sharepoint

Running high trust apps / plugins with Sharepoint Foundation 2013

The User Profile service is not available on Sharepoint Foundation and therefore high trust apps are not supported.   However I found that after installing a high trust app it worked until restarting IIS, and after that it would generate authentication errors.  Re-uploading the app package to the app site fixed the authentication errors and allowed the app to run properly again.

I could not find an API to automate this re-upload process, so instead it can be done using a headless browser.

Here’s an example in casperjs (note that on Windows casperjs must be installed in a path without spaces):

[sourcecode language=’js’]

var url = ‘https://yourdomain.com/sites/appcatalog/_layouts/15/start.aspx#/AppCatalog/Forms/AllItems.aspx’
var file = ‘sharepoint-package.app’
var user = ‘username’
var pass = ‘password’

var casper = require(‘casper’).create();

casper.setHttpAuth(user, pass);

casper.thenOpen(url, function() {
this.waitForSelector(‘#idHomePageNewDocument-WPQ2’, function() {
this.echo(“Found selector”);

casper.thenClick(‘#idHomePageNewDocument-WPQ2’, function() {
this.echo(“Clicked button”);
this.waitForSelector(‘.ms-dlgFrameContainer > iframe’, function() {
this.echo(“Got the iframe”);

casper.withFrame(1, function() {
this.waitForSelector(‘#aspnetForm’, function() {
this.echo(“Found form”);
this.fill(‘#aspnetForm’, {
‘ctl00$PlaceHolderMain$ctl01$ctl04$InputFile’: file,
}, false);
this.wait(3000, function() {
this.echo(“Clicked button”);


The term ‘Get-SPApplicationPrincipal’ is not recognized as the name of a cmdlet, function, script file or operable program.

Ignore what it says on this technet page: http://technet.microsoft.com/en-gb/library/jj219714(v=office.15).aspx

The command is actually Get-SPAppPrincipal.

You can see the correct command here: http://technet.microsoft.com/en-us/library/jj219664(v=office.15).aspx



Sharepoint 2013 Provider-Hosted App Architecture Notes

Trying to build a Sharepoint 2013 app has probably been the worst experience of my coding life so far.

The Microsoft docs make it sound so easy; there are so many ways you can build an app!  You can use any programming language you like!  Look, we have a REST interface!  Look, mobile app APIs!

Hey awesome,  you think, looking through the initial introductory documentation, yeh all the different information is a bit confusing, but look, they have how tos and the APIs are documented properly, how hard could it be?

Well, after wasting A LOT of time following guides and trying to build solutions that work, here’s some information that happened to be crucial to the architectural decision making of the apps that I didn’t come across until much too late.  Probably it’s wrong, because I’m finding it extremely difficult to get actual facts about the different ways you can build sharepoint apps, despite the millions of confusing articles on the Microsoft site (none of which seem to contain all the information you need to know), and lots of tutorials (written only by people coding in ASP hosting their sites on Azure or using OAuth).


Provider-hosted apps using the REST API:

  • You can either use the javascript cross-domain library or use OAuth
  • Using OAuth requires an account with Azure AD and you also need to configure your Sharepoint installation to use Azure AD (and obviously the Sharepoint installation needs access through firewalls etc to communicate to Azure AD).  In addition, the app needs to be registered in Azure.
  • I’ve seen some tutorials that say for testing you just need to register the app in SP and not Azure, and that you don’t need the Azure AD in this case; I couldn’t get this to work.

Provider-hosted apps using high trust:

  • The how-to guides all use a couple of Microsoft provided C# files for the authentication, in addition to Windows Authentication for the site in IIS, and I can’t see any documentation on how the process actually works.  Reading through the files, they get the Windows user information, so I have a feeling this method can only be used for apps built (1) in ASP/C# running on a windows machine, and (2) in the same domain as the sharepoint installation.


So if you want to build an app that can modify sharepoint data in any non-Microsoft language, and host it on a non-Windows machine, and don’t want to pay for an Azure subscription, and don’t want to change the authentication method of your sharepoint site, your options are:

  1. Javascript frontend to deal with Sharepoint, plus likely a backend of whatever to do anything you can’t with javascript (use 3rd party APIs etc)
  2. A high trust app to act as a proxy between your app and the sharepoint installation*

*I’m still trying to figure out how it would be possible to send the REST request I want to make to sharepoint to the proxy instead, and have that sign it and forward it on to sharepoint…

Migrator Dragon for SharePoint 2013 fixing crash on ‘increase max upload file size on server’

When trying to upload files using this tool, the max upload size is 3MB (mentioned here: http://gallery.technet.microsoft.com/office/The-Migration-Dragon-for-c0880e59#content)

To increase, you need to use this button on the tool, but it was crashing for me with the following error:

Description: The process was terminated due to an unhandled exception.
Exception Info: Microsoft.SharePoint.Administration.SPUpdatedConcurrencyException

In addition to this, I was getting lots of other errors from SharePoint:

The Execute method of job definition Microsoft.SharePoint.Diagnostics.SPDiagnosticsMetricsProvider (ID 7f18b8c7-49aa-45f2-8826-67ecff862c1a) threw an exception. More information is included below.

An update conflict has occurred, and you must re-try this action….

These two errors are linked, and the solution is described here: http://support.microsoft.com/kb/939308 (although the details were slightly different on my installation, Win Server 2008 R2 and SP 2013)

To fix, you need to stop the SharePoint Timer Service, clear the configuration cache (at C:\ProgramData\Microsoft\SharePoint\Config\[guid], one folder has XML files, the other persistedfiles) by deleting all the XML files (not the folder, also the KB article mentions not to remove the cache.ini file and to edit it, but I didn’t have one), and restart the SharePoint Timer Service.  The article also mentions to run a config refresh from SP admin, but I couldn’t find this, so didn’t do it, and the fix worked anyway.  Might need to restart IIS as well.


(Also note, I think the max you can set the button is the value that you set for the application max file upload.  SharePoint 2013 has a hard limit of 2047 MB, so you can put this value in both the SharePoint web application settings and Migrator Dragon and you’ll be able to upload large files up to 2GB.  To change in SP, Central Administration > Manage Web Applications > select your application and go to General Settings >  Maximum upload size)