Sunday, August 28, 2011

What to do when your Sharepoint WebPart is causing authorisation issues

Whilst working with a client to customise some of their public facing Sharepoint pages I developed a number of custom web parts.  One of these web sites was getting some of its information by enumerating the different sub sites of the site collection.  Unfortunately while this worked well when the site’s users were authenticated it didn’t work if they were anonymous users, which of course the majority of the sites users would be.  When an anonymous users navigated to a page with this webpart they were prompted for their credentials.

There is a simple solution to this problem which is to us the SPSecurity.RunWithElevatedPrivileges method, passing in a delegate to the work that is requiring authentication.  Your code would look something like this:

Sunday, August 21, 2011

GuessWho a sample data library

I just published by first nuget package.  It is a library for generating sample identity information.  It allows you to write code like this:

Which produces this output:

For more information I recommend you check out the project page over at github or bitbucket.