Saturday 29 June 2013

SharePoint Host Apps - User Permissions

Problem:  How do I give users or groups permissions in a SP Host App?  This post is not looking at giving the App Web permissions against the SharePoint Site.  It merely looks at giving users rights to work within the app.

Initial Hypothesis:
SharePoint has a structure Object hierarchy that developers can secure users against namely: SPSite (Site Collection), SPWeb (Sitess/Webs), SPList (Lists/Document Libraries) and SPItem (Rows).  Based on the hierarchy I initially assumed SP Apps would maintain their own security.  Well this would get rather confusing as you would need to maintain the host web and the app web user permissions.

There is no UI in the App web to be setting security but on the UI you can get to the lists permission page.  In the SP Hosted App, navigate to the list, in my case the url is: http://dev-d8f436fea0378f.apps.dev.local/SPHostedApp/Lists/Comment/AllItems.aspx this takes me to the "Comments" list.  I click the "List" tab on the ribbon.  Click the "Shared With" button and Choose "Advanced".


Here we can stop inheriting the security permissions for the list.
I thought I could set the App webs permissions by selecting the "Web" link.  You receive an error.

Resolution:  You need to stop inheriting permissions on the Host App (parent) and then the App web inherits theses permissions.

How if works:
 

Friday 7 June 2013

Why I like VS/TFS 2012 no I mean VS/TFS 2013


Visual Studio (VS) 2013 and Team Foundation Server (TFS) 2013 is being released in the next few weeks - that was quick.  I'm just getting comfortable with VS 2012 and the announcement comes that VS 2013 is being released later this month.

http://blogs.msdn.com/b/bharry/archive/2013/06/03/visual-studio-2013.aspx

So, this is going to be a blog on VS 2012 with TFS, my number 1 favourite new feature in VS 2012 is local workspaces.  Pre VS2012 all workspaces were Server based workspaces.  "Local" workspaces differ in that when you go offline you have version control on your local machine.  You can rollback/compare to an old version.  So for me and my laptop on client sites I find it a big improvement.  Very simply this is how GitHub works (from my extremely limited knowledge of GitHub).  You have local version control and this is synced up with the central source control repository.

Another feature worth looking at will be Release Management.  I am working with TeamCity to build my Infrastructure (PowerCli for VMware and Powershell to build SQL Server.  Autoinstaller runs the SP part).
TFS 2012 - Scrum template home page

Team Rooms are already on TFSPreview, seems like a nice idea - not sure how the takeup will be from devs.

Saturday 1 June 2013

Retrieving lookup list columns using REST SharePoint 2013 API

Problem:  I have 2 related SharePoint lists: 1) Question and a Child (linked) list 2)Comment.  I need to perform an JS call using jQuery to retrieve a specific comment item and I need to also know the Title field from it's related parent list (Question).  The 2 lists are shown below.  The post Creating related lists for SP Hosted Apps using VS2012 show you how to do this.

Resolution:
Open you browser  and check the query works:
http://dev-d8f436fea03755.apps.dev.local/SPHostedApp/_api/web/lists/getByTitle('Comment')/items(1)?$select=*,Question/Title&$expand=Question/Title
(replace the url)

jQuery Ajax code I used to call the REST API is shown below:

The ajax call is made in the document.Ready() method call.

Tuesday 21 May 2013

AccessDeniedException when deploying Rdl to SP2010 Claims based site


This Post by Adam Saxton saved me hours of time today.

http://blogs.msdn.com/b/psssql/archive/2012/07/12/sharepoint-adventures-access-denied-errors-when-using-rs-2012-with-a-claims-sharepoint-site.aspx

I setup SP2010 with SQL 2012, all appeared to be working until I create a rdl and tried to deploy it into SharePoint from BIDS in VS2010.  Got the error: The permissions granted to user are insufficient for performing this operation. reporting services + AccessDeniedException.

Resolution: This is a permissions issue on the SharePoint site, I opened the url http://<sitecollection>/_layouts/people.aspx?membershipGroupId=0

I had 2 identical accounts: demo\administrator & DEMO\Administrator.  I ran the select statement explained by Adam to check the user table on the content db where the site collection sites:
SELECT tp_login, tp_title, tp_delete from UserInfo

I deleted the NT account (not the claim account) using the SP UI (http://<sitecollection>/_layouts/people.aspx?membershipGroupId=0).  Re-ran the T-SQL query and the offending NT account (DEMO\Administrator) has been virtually deleted by SP.

I can now publish the report.



More Info on setting up SSRS for SharePoint:
 

Sunday 19 May 2013

Creating related lists for SP Hosted Apps using VS2012

Problem:  SharePoint Hosted apps need to use their own site collection (app site collection) to hold list data.  In this post I look at setting up 2 lists that are related.  To clarify what I am trying to achieve I have created an Entity Relationship Diagram (ERD) below.

Initial Hypothesis:  Provisioning fields, content types, list definitions, list instances and seed data is fairly similar between SP2010 and SP2013 within an App.  The VS2012 tooling is good OOTB and I am using a few simple xml based tweaks to get them working as I like them.

Resolution:
Open VS2012 ensure you have the SharePoint developer addin and create the Question list as shown below.
 

Amend the list to show your fields:



Hit F5 to debug the App, edit the url to view the list you created.  My url after I edited it is shown below:
http://dev-d8f436fea036f6.apps.dev.local/KB-SPHostedApp/Lists/Question

Question list is working















Repeat the list setup process in VS for the "Comments" list.  We will start from the step where you add the related look to the Posts list.

Working Result:



Wednesday 15 May 2013

Impersonation over elavation in SharePoint code

Tip:  In managed code in SharePoint use Impersonation over elavation.

 

Tuesday 14 May 2013

Compare Files Easily

Problem:  Often need to compare files and i recently had such a case where I needed to check PS1 and xml based files on my build server needed to be the same as in TFS.  I had been fairly slack and needed to verify they were the same. 

Resolution: BeyondCompare is a great tool for comparing files but I really like CodeCompare from Devart.  It has VS 2010 integration as well as the console that is shown below.


http://www.devart.com/codecompare/
http://visualstudiogallery.msdn.microsoft.com/dace3633-0b51-4629-85d4-c59cdce5bb3b/