Wednesday 23 May 2012

Retrieving Claims Values in SP2010

Problem:  Developer wants to retrieve values from the users claim to send an email.

Intial Hypothesis:  Create a web part to demonstrate the code that displays all the claim values.  Pull out the claim values such as the UPN in my case and send an email to the current user based on the upn value.  The upn in my dev machine is the users email address but it obviously depends on how you claims are setup.

Resolution:  Create a new SharePoint project and add a web part.  Then add the code as shown below.
Updated 28 May 2012 - Format of claims post
Example from ADFS2.0 connecting to AD:  "i:0ǽ.t|mkting|testuser"

User Information List

To see a site collection's hidden user information list append /_catalogs/users/simple.aspx onto the end of the site collection url.
Example:
http://claims.demo.dev/_catalogs/users/simple.aspx

How User InfoWorks?
When a user is given permission to the site collection or the 1st time the user log in, their credentials/user info gets added to the UserInfo list.  The UserInfo user data does not get added to the list when a user is added via AD groups; only when the AD added end user logs into the site collection for the 1st time do they get an entry in the list.
Note: The UserInfo list entry is not added if you pick the user in a list within a people picker column.

For the display of a specific user: _layouts/15/userdisp.aspx?ID=25&Force=True

I get the users Id in the UI by appending this to the URL: /_layouts/15/people.aspx?MembershipGroupId=0 
I then find the user and find their Id and use this URL in the browser to see the user info:
/_layouts/userdisp.aspx?id={UserID}&Force=True

Thursday 17 May 2012

Timer Job Paused

Problem:  One of our environments was not running timer jobs and had 17 timer jobs in a status of "paused".
Initial Hypothesis: I replicated the pause timer jobs on a dev machine.  I removed the cache and the paused jobs were still present.  Performing a PSConfig fixed the timer job issue but broke my User Profile Service (UPS).  So not a viable fix.
Resolution: One of the engineers worked out that another engineer had played with the OWSTIMER.EXE configuration had been changed and once corrected, the time jobs flushed themselves out.

Wednesday 16 May 2012

User Profile Service Sync Setup

Overview:  This post assumes UPS is setup and work and merely shows how to amend the synchronisation of AD with the User Profile Service (UPS).










Verify the Synchronisation has run:




Sources/More Info:

http://www.harbar.net/archive/2011/07/12/332.aspx
http://www.harbar.net/archive/2011/02/10/account-deletion-and-sharepoint-2010-user-profile-synchronization.aspx

Monday 14 May 2012

Creating Custom Service Applications

I recently got some help from Amardeep Bhogal (Amar) for a project.  Rather than me re-hash the conversation take a look at his post with sample code.

"The purpose of this sample code is to provide the reader with an insight into how SharePoint 2010 Service Applications can be used to create truly distributed scalable architecture."

Source: http://code.msdn.microsoft.com/sharepoint/SharePoint-2010-Service-4dbde25b

Tuesday 1 May 2012

Storing Application Level Setting

Problem:  In a large On Premise farm holding several web applications (web app) I have multiple custom coded applications per web app. 

Initial Hypothesis:
  • Storing the custom apps config settings in the web config is at the wrong level and dangerous to modify even using SharePoint features. 
  • Using a list is an option however configuration could span site collections.  Additionally, security would need to be set and access granted to the appropriate people on the config list - still me favourite option especially when adding caching.
  • I have also use property bags but have need to maintain this via PowerShell.  A lot of developers like this option but without UI I felt it was not worth the effort to use/maintain and document this over using web.configs. 
Resolution:
The CodePlex project "SharePoint Property Bag Setting 2010" (PBS2010) is a great tool for replacing the developers technique of using the web.config.  The package is deployed at farm level and administration screens are provided on the Central Administration site for the farm.  PBS2010 can be extended to allow Site Collection administrators to edit the settings themselves but if this is required I would use a configuration list at the root SPWeb for the Site collection.  This is a nice codeplex project that I will definitely leverage going forward.


Below is a Powershell snippet to add a property to the property bag on the default SPWeb on a site collection:
$url= 'http://me.demo.dev/sites/PaulBeck'
$site = Get-SPSite($url)
$rootWeb = $site.RootWeb
$rootWeb.AllProperties.Add("Age","25")   # Sure Pal
$rootWeb.Update()
$ht = $rootWeb.AllProperties  # Display the hash table

Update 2015-12-15:  You can also append the url and view the RSS feed to see property bag values
http://me.demo.dev/sites/PaulBeck/_api/web/allproperties

Also See:
Microsoft have a very nice code block for setting and getting property bag settings.
http://msdn.microsoft.com/en-us/library/ff798340.aspx
It uses a unique naming convention which I'm not too happy with but I guess it so dev's don't accidentally modify or delete property bag setting set by the product.

Monday 23 April 2012

ISC London 2012

Monday 23/04/2012:  I missed the keynote and went to the IT Pro track sessions.  I'm not sure about this follow on format being used for the entire conference.  I prefer conferences where each session is packed with speaker tips and allows for delegates to switch between tracks.  Saying that the speakers were good and the sessions are well planned. I still have plenty to learn on the IT Pro track so looking forward to Tuesday.  Was good to see old colleagues and meet some new people.
  • Powershell build and configuration sessions were excellent.
  • SQL tips were good.
  • User Profile session was great to follow despite being way to advanced for my UPS understanding.
Tuesday 24/04/2012:  I went to the 1st 2 developer sessions with Mirjam van Olst & Waldek Mastykarz.  Nice sessions with great perspective on development.  I went to the search session and found these especially the 2nd session with Neil Hodgkinson enlightening.  For the last session of the day I went to Kimmo Forss session on migration, not a technical session but very important and I find Kimmo to be a interesting speaker to listen to.  I think the key from Kimmo's session for me is plan & analyse don't just jump in.

Summary: I am coming around to the follow on sessions idea however, I still prefer the traditional standalone barrage me with ideas approach.  It was good to listen and speak to people with a wide range of roles/experiences in SharePoint over the conference.  This is a good conference and I get a lot of information from these conferences.