Archive for October, 2013

SharePoint User\Group columns and People Picker Controls

So recently I had to perform some custom code that would add an entry from a people picker control to a user\group column and back again (on another form).  Going from the people picker control to SharePoint is really easy (the code snippet’s below are obviously vb.net.  I am trying to keep most of my examples on this site in C#, but this particular client I wrote this for was a VB shop at the time).


 

Next, cast the value to an SPUser type and update the list. Please note: I realize some of you may be wondering why I am not going directly from the people picker to SPUser.  The reason being is that in most cases you are updating more than one field at a time and I wanted to show you a method (at least the one I use) to store columns of multiple types

 

That may seem like a lot of code just to upload, but remember it was written to handle more than just the one column. It also illustrates a method to upload an entire list row’s worth of data.

Now to go from a User Column to a people picker is quite a bit less code because I am only doing it one column at a time and access the column directly.  I am not building a dictionary to hold different field types nor updating a number of fields at once.  However, I do think that going from a User column to a People Picker is a bit more convoluted.  You actually first cast the user column into a SPUser object, then you put the user object’s login name into a Picker Entity.  You then add the picker entity to an ArrayList and finally you then add the array list to the picker object.

 

So hopefully this illustrates a method that can be used to take a value from a People Picker in a custom form up to SharePoint and then back again.

Creating a complete installation of SharePoint 2010 without needing a domain

SharePoint 2007 allowed for a complete farm installation of SharePoint without the need of a domain.  It would have been nice to carry this on with SharePoint 2010, but unfortunately Microsoft decided this wasn’t important and instead provided a method to perform a “stand-alone” install.  The stand-alone install is great for business users and demonstrators who are trying to show off products to prospective clients as a fairly high-end laptop is all you need (thus you don’t really want a domain as it will be used in a mobile setting).  This solution does not work well for developers and\or other users that would like to use a full SQL 2008 install instead of SQL Express that is used in a stand-alone install.

Enter PowerShell.  With PowerShell you can configure SharePoint to install a full version, connect to a full version of SQL 2008 and create content DBs all without the use of domain accounts.  This is extremely useful for developers who travel with laptops and don’t want to have to worry about domains.  Be warned though, some products like PowerPivot do require domain accounts (no workaround that I am aware of) and if needed pretty much make what I am about to show you pretty useless.

There are some preparation steps you need to do first (you don’t have to do this, but I found it saved some headaches later).

  1. On your PC\Laptop\VM create an account that you wish to use to connect to the SQL DB.  Basically make this your farm account.
  2. Make this account an administrator on the server you are installing SQL and SP on.

Setup instructions:

  1. Create a SharePoint Farm account (ex. SP_Farm).  This account does not require administration rights to the system.
  2. Logged on with an administrator account, install SharePoint Server.
  3. When prompted for type of installation, select Server Farmimage
  4. When the installation is complete remove the check mark for: Run the SharePoint Products and Technologies Configuration Wizard now.
  5. Next log out of the system.  And login with the administrator password you created in the preparation steps.
  6. Click on Start -> All Programs -> Microsoft SharePoint 2010 Products.  Right click on SharePoint 2010 Management Shell and select Run as administrator.
  7. This is where PowerShell allows you to setup SharePoint without a domain account.  Type in the following command within the PowerShell command window you opened up:

[code language=”powershell”]<br /><br />New-SPConfigurationDatabase -DatabaseServer "ComputerName" -DatabaseName "instance\DBname" -FarmCredentials "computername\farm account" -Passphrase "passphrase used to connect SP servers to the farm"<br /><br />[/code]

Once that command is complete you can now complete the SharePoint 2010 Products Configuration Wizard.