A blog by Pilothouse Consulting
Posts tagged SharePoint 2010
Dual Purposed Visual Web Parts
Mar 4th
So while teaching a class the other week, I was asked how to implement a “widget.” This widget may be a web part and available on certain pages within sites, but may also be something that needs to be placed in a master page to show up everywhere. The point is that the developers don’t know up front how the widget will be used. Also, remember that Web Parts should not be included in the Master Page. Yeah, you can get them in there; but you have to be careful to put them after the Web Part Manager. Designer won’t even let you try to place them without manually typing the tags in.
I was in the last day of the course, where I offer to “just do” something that they will need to implement so they can see the thought process that went into it. In retrospect I should have come up with the idea immediately, but from start to working proof of concept (including the actual functionality) for their example was only 20 minutes.
After some “thinking out loud,” I came to the conclusion that a Visual Web Part would solve their problem in one fell swoop.
A Visual Web Part is one that is merely a wrapper for a control, and the expected development case is to do all of your coding inside the control itself. The Web Part piece of it merely loads it in the overridden CreateChildControls method and displays it to the user. So what you’re left with is a control in the SharePointRoot/Template/ControlTemplates folder on disk, and a web part in the gallery.
The key insight here, which very well may be pointed out in literature that I haven’t read, is that you could also directly place the control onto any safe or master page in SharePoint. Putting it into the Master Page will also effect Application Pages in SharePoint 2010. You end up with a Control and a Web Part for free.
Note that using a Visual Web Part takes away your ability to Sandbox the solution package, and if that is an issue you’ll need to come up with an alternate solution. Was that a pun? I’m not sure.
In Summary: A Visual Web Part also gives you a control, which could be added directly to master pages (or anywhere else) if your deployment needs change.
Site Templates with Site Columns
Feb 25th
The image above lays out a potential situation that can be created in any SharePoint deployment. What happened was that a site column was created in a site, and that site was later saved as a template. At that point, it was available for use throughout the site collection in question, and some sites were created based on the template.
What happens is that the site column ends up in the gallery for each site using it – sites A and B (in magenta) in the graphic above.
The normal behavior for site columns is that they are available at the site in whose gallery they reside, as well as any subsites. From a subsite the column is not editable, and when you go back to the site where it exists changes can be pushed down to any list using that column. But what really happens?
Create the situation above, and use a choice column for the site column that is part of the template. Give it some choices, save the template, and then go make some sites based on the template. Make sure that they are not part of the same subtree (as in the image), just to really drive the point home.
Make some lists in both sites based on your choice site column.
Now, update the column in the gallery for site A by adding a new choice, and have it propagate changes to all subsites. Look at the lists using that column in site A. The list column based on that site column will have been updated, which is the expected behavior.
What comes next could be unexpected. Look at the list columns in Site B. Those based on the choice site column that you created will also have the new option available.
Next could be even more unexpected. Check the site column gallery for site B, which also has the same site column defined. That version of the site column will be unchanged.
You could continue the experiment by modifying the gallery version of the column in site B, telling it to propagate changes below, and watching the change also effect site A’s versions of the columns in its lists.
So what is going on here?
When a site column is defined, SharePoint creates a GUID to associate with it. You can see what I’m talking about by checking any feature in the SharePointRoot/Features folder on disk, and noting that there is a globally unique ID associated with it. When you modify a site column in a gallery and tell it to push down changes, it looks at every LIST column in that site collection, and based on that ID swaps out the definition. It does not, however – as our experiment showed, update anything defined in any gallery.
Now, this behavior is completely fine almost all of the time. If you have two disparate sites with different galleries and manage to give two distinct site columns the same name, they will still have different IDs. If there is a parent-child relationship, it will be disallowed and you’ll be forced to update only the parent version, as the child gallery will show the column as read-only. We defeated the use case by putting our column into a site template and using that instead, which preserves the ID.
Will this behavior happen across site collections? Not at all, even in the same content database. Try it to find out.
You may wonder if this behavior applies to site content types as well. Try it, and post your results.
The morals of the story are to be careful when putting site columns into site templates, and that you can learn a lot about how SharePoint operates by tinkering with your ideas and questions. Since behavior is subject to change across versions of the product (even minor patches), it is always best to try things out before assuming certain behavior.
In Summary: Define a site column in a site template, make sites based on that template in various locations in your site collection, use the site column in lists. Now updating any gallery version of the site column will update every list using it, regardless of the tree position of the list.
SharePoint Training DVD Labs Updated and Fall Schedule is Up
Aug 14th
We have updated the labs with minor bug fixes that we found over the last three months. You can get the latest updates
If you are interested in a class our SharePoint Training Fall Schedule is up:
Configuring Kerberos in SharePoint 2010
Aug 13th
When installing SharePoint for the first time, there is an option to use either NTLM or Kerberos. Kerberos is recommended, but the caveat that they give you is that additional steps need to be taken by an administrator to make it work.
On older server versions (Windows Server 2003 R2, for instance) you could pick Kerberos from the get-go and continue setting everything up as long as you were logged in as an Administrator. Later on you’d find that nobody else could log in until an administrator set up the SPNs, and at that time you’d be setting them up (typically via command line).
If you’re installing SharePoint 2010 onto Server 2008 R2, though, Central Administration won’t even load until those same SPNs are set up. This post is intended as a quick walkthrough of how to do it if what I just said made no sense.
In our case (for our test environment) we’re using the domain abcuniversityph.edu (does not exist – we just use this sample for class), have gone through the steps to install SharePoint, and have told it to use Kerberos for authentication. We then tried to load Central Administration and it wouldn’t allow us to log in.
Our next step is to use the ADSI Edit utility, which can be launched by typing adsiedit.msc in the search/run textbox from the start menu.
When that comes up, we need to locate the Administrator Container.
As you can see, we had to go to our domain, then choose the Users Container, and found Administrator in there.
At this point we’ll right click on the Administrator container, and choose Properties. From there, we locate the servicePrincipalName property and edit it.
For our example, the necessary line to add (just for Central Administration) was the http/abcuniversity.abcuniversity.edu:7777 line, as our Central Administration Web Application happens to be running on the lucky port 7777. Note that it takes the form of protocol/fully qualified computer name:port. We also added a line for the computer name on port 80 (by leaving the port off) so that the demo web applications that we create are also accessible.

At this time it’s enough to “OK” our way out of the utility, saving our changes along the way, and continue to set up the environment in your now more-secure environment.
Virtual Image User and User Profile Creation PowerShell Script Update
Aug 12th
For user profiles demos, it’s nice to have some sample profiles in there. For SharePoint 2007 image, we used a script to populate Active Directory users with the proper information and then just do an import to SharePoint. For SharePoint 2010 image, instead of using Active Directory. we are using local user accounts, so the script had to change. Now we take the user profile information from the same CSV file that’s used to create local accounts.
Here is the PowerShell script:
# SharePoint 2010 Workstation create users and user profiles script
# Pilothouse Consulting, Inc. Feel free to distribute and modify it.
$computer = [ADSI]"WinNT://$env:computername"
$userslist = import-csv users-list.csv | Select username, fullname, firstname, lastname, department, jobtitle, manager, skills, email
foreach($singleuser in $userslist)
{
$user = $computer.Create("user", $singleuser.username)
$user.SetPassword("Training45")
$user.SetInfo()
$user.FullName = $singleuser.fullname
$user.Description = "SharePoint sample user"
$user.SetInfo()
}
$site = Get-SPSite "http://abcuniversity"
$serverContext = Get-SPServiceContext $site
$upm = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($serverContext)
foreach($singleuser in $userslist)
{
$accountName = "abcuniversity\" + $singleuser.username
if ($upm.UserExists($accountName))
{
$up = $upm.GetUserProfile($accountName)
}
else
{
$up = $upm.CreateUserProfile($accountName)
write-host "user" $accountName "profile created"
}
$up["FirstName"].Value = $singleuser.firstname
$up["LastName"].Value = $singleuser.lastname
$up["PreferredName"].Value = $singleuser.fullname
$up["Department"].Value = $singleuser.department
$up["Title"].Value = $singleuser.jobtitle
$manager = "abcuniversity\" + $singleuser.manager
$up["Manager"].Value = $manager
$up["SPS-Skills"].Value = $singleuser.skills
$up.Commit()
write-host "user" $accountName "profile updated"
}
Here is the CSV file:
username,fullname,firstname,lastname,department,email,jobtitle,manager,skills
davegreen,Dave Green,Dave,Green,Graphic Design,DaveGreen@abcuniversity.com,Professor,bettytwain,Presenting
lucysmith,Lucy Smith,Lucy,Smith,Chemistry,LucySmith@abcuniversity.com,Professor,martharollings,Researching
bobjohnson,Bob Johnson,Bob,Johnson,Graphic Design,BobJohnson@abcuniversity.com,Student Researcher,davegreen,Researching
davesmith,Dave Smith,Dave,Smith,Graphic Design,DaveSmith@abcuniversity.com,Student Researcher,bobjohnson,Researching
martharollings,Martha Rollings,Martha,Rollings,Chemistry,MarthaRollings@abcuniversity.com,Department Head,administrator,Researching
judybright,Judy Bright,Judy,Bright,Chemistry,JudyBright@abcuniversity.com,Student Researcher,lucysmith,Presenting
tracywright,Tracy Wright,Tracy,Wright,Chemistry,TracyWright@abcuniversity.com,Student Researcher,lucysmith,Researching
alexbrown,Alex Brown,Alex,Brown,Chemistry,AlexBrown@abcuniversity.com,Professor,martharollings,Presenting
kellybrennan,Kelly Brennan,Kelly,Brennan,Chemistry,KellyBrennan@abcuniversity.com,Student Researcher,lucysmith,Researching
georgemason,George Mason,George,Mason,Graphic Design,GeorgeMason@abcuniversity.com,Student Researcher,davegreen,Researching
gregwalter,Greg Walter,Greg,Walter,Math,GregWalter@abcuniversity.com,Student Researcher,lisasimmons,Researching
clairejohnson,Claire Johnson,Claire,Johnson,Math,ClaireJohnson@abcuniversity.com,Department Head,administrator,Presenting
lisasimmons,Lisa Simmons,Lisa,Simmons,Math,LisaSimmons@abcuniversity.com,Professor,jeffbridges,Researching
jonstew,Jon Stew,Jon,Stew,Graphic Design,JonStew@abcuniversity.com,Professor,jeffbridges,Researching
bobbush,Bob Bush,Bob,Bush,Math,BobBush@abcuniversity.com,Student Researcher,lisasimmons,Presenting
marysimmons,Mary Simmons,Mary,Simmons,Math,MarySimmons@abcuniversity.com,Student Researcher,lisasimmons,Presenting
donnabridges,Donna Bridges,Donna,Bridges,Graphic Design,DonnaBridges@abcuniversity.com,Professor,bettytwain,Researching
jeffbridges,Jeff Bridges,Jeff,Bridges,Math,JeffBridges@abcuniversity.com,Department Head,administrator,Researching
jerryboss,Jerry Boss,Jerry,Boss,Graphic Design,JerryBoss@abcuniversity.com,Professor,bettytwain,Presenting
bettytwain,Betty Twain,Betty,Twain,Graphic Design,BettyTwain@abcuniversity.com,Department Head,administrator,Presenting
administrator,SharePoint Admin,SharePoint,Admin,Chemistry,administrator@abcuniversity.com,SharePointer,davegreen,SharePoint
You can modify the scripts for your own demo environment, or if you going through SharePoint Training DVD labs, just run these on the current image. All the future images will sample user profiles.
SharePoint 2010 requirements are ahead of most laptops for training purposes
Jun 21st
In the last public SharePoint 2010 class we had to provide preconfigured laptops to about 70% of the students. Surprisingly many laptops with 4GB of RAM and Intel processors do not support virtualization on the chip and many come with 32 bit OS which wastes about 1 GB of RAM.
I am still surprised that Microsoft is pretty much killing Virtual PC by not allowing guest 64 bit operating systems when many of its new products are 64 bit only. We’ve used Virtual PC since 2003, but now it’s all VMWare as it’s the only viable solution for training. Sure MS recommends other options that we ruled out after spending enough time to realize that they would be a nightmare in a classroom environment.
- Booting from a VHD. If you do it right it works well. If you mess it up (and don’t back up the boot record), you are in real trouble
- Using Hyper-V. Well, how many people do you know that run Server 2008 on their laptops?
- Installation of all software on Windows 7 is possible, but not something that you should expect from a student before class.
Setting up VMWare image takes 10-20 minutes which is about how much time you have before someone gets frustrated with setup. Hopefully, people will keep upgrading their laptops to processors that support virtualization, solid state drives, and 64 bit operating systems. This way we don’t have to ship big boxes to/from DC.
Designer Workflows and Event Handlers
Jun 16th
A savvy student in a SharePoint 2010 class today asked about event handlers and Designer workflows. As I am wont to do, I just “did it” to see exactly what happened.
When having a Designer workflow (associated with a list) kick off automatically, an ItemAdded and ItemUpdated event handler are attached to the list in question to handle said kickoff. If you want to have some code run via event handler before the workflow starts, your best bet is to use ItemAdding, as ItemAdded won’t be guaranteed to run before the workflow starts.
This is one of those cases where the term “asynchronous” with regard to the ItemAdded event handler can be taken to mean what the actual word means, instead of as a substitute for “after.”
Top Five Improvements in SharePoint 2010
Jun 14th
- Using InfoPath to edit list forms – no longer there is a need for a developer to design form layout, logic, and conditional formatting.
- List navigation based on metadata – the best of both worlds: hierarchical navigation by folder, or metadata navigation based on column values.
- More consistent terminology and cleaner pages – for example, permissions management pages are no longer confusing.
- Clean and fast SharePoint Designer – it’s easier to make improvements when you start from scratch and that’s what SharePoint team did here. Better workflows and ability to create external lists and content types are a great plus.
- Cleaner Central Administration and PowerShell – No need to develop .net console applications, script anything using PowerShell
Overall the trend continues to configuring more out of box and only developing functions that add immediate value.




