<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://suguk.org/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>The MOSS-pit</title><link>http://suguk.org/blogs/the_moss-pit/default.aspx</link><description /><dc:language>en-US</dc:language><generator>CommunityServer 2.0 (Build: 60210.2610)</generator><item><title>Error when creating an SSP - &amp;quot;Unable to Create SSP - Provisioning failed: Windows NT user or group 'XXXX' not found</title><link>http://suguk.org/blogs/the_moss-pit/archive/2010/04/14/23589.aspx</link><pubDate>Wed, 14 Apr 2010 15:37:00 GMT</pubDate><guid isPermaLink="false">19180fc3-a95d-4057-992e-fee77d73db0e:23589</guid><dc:creator>AussieNigel</dc:creator><slash:comments>0</slash:comments><comments>http://suguk.org/blogs/the_moss-pit/comments/23589.aspx</comments><wfw:commentRss>http://suguk.org/blogs/the_moss-pit/commentrss.aspx?PostID=23589</wfw:commentRss><description>&lt;p&gt;A colleague of mine encountered this error when attempting to configure a new SharePoint install from scripts.&lt;p /&gt;

&lt;p&gt;After some soul-searching and much swearing, we found the error to be caused by SharePoint not liking its accounts to contain Fully Qualified Domain Names.  He had specified all of the accounts (farm creation acc, search accounts, app pools etc.) to be something like "Domain.Qualifier\AccountName".&lt;/p&gt;

&lt;p&gt;The resolution was to specify the accounts like "Domain\AccountName".&lt;/p&gt;

&lt;p&gt;As this was scripted, we decided to simply roll-back the environment to the previous snap-shot, then re-run the scripts with the accounts changed, however it is probably possible to delete the SSP, change the accounts using STSADM commands and then recreate it.  These posts would help if that is the tack you decide to take:&lt;/p&gt;

&lt;p&gt;- http://www.stationcomputing.com/scblogspace/Lists/Posts/Post.aspx?List=ec6ce151%2D566a%2D499e%2D94a5%2De153fafda404&amp;ID=35&lt;/p&gt;

&lt;p&gt;- http://support.microsoft.com/kb/934838&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Note:&lt;/b&gt; you may need to ensure your NICs have NetBIOS support enabled for them to recognise the unqualified accounts.&lt;/p&gt;&lt;img src="http://suguk.org/aggbug.aspx?PostID=23589" width="1" height="1"&gt;</description></item><item><title>Creating a Kerberos-authenticated MOSS Farm by Script</title><link>http://suguk.org/blogs/the_moss-pit/archive/2010/03/29/23354.aspx</link><pubDate>Mon, 29 Mar 2010 12:22:00 GMT</pubDate><guid isPermaLink="false">19180fc3-a95d-4057-992e-fee77d73db0e:23354</guid><dc:creator>AussieNigel</dc:creator><slash:comments>1</slash:comments><comments>http://suguk.org/blogs/the_moss-pit/comments/23354.aspx</comments><wfw:commentRss>http://suguk.org/blogs/the_moss-pit/commentrss.aspx?PostID=23354</wfw:commentRss><description>&lt;p&gt;I recently had a requirement to use a scripted approach to create a SharePoint farm that used Kerberos authentication.&lt;/p&gt;
&lt;p&gt;A quick bit of research pointed me towards the excellent resources made available by Gary Lapointe (see his blog at http://stsadm.blogspot.com/).&lt;/p&gt;
&lt;p&gt;Gary has created and made freely available a huge number of really useful custom STSADM commands and Powershell commandlets, as well as going through the code used to create them.  It really is an excellent resource he has created, and well worth spending some time going over all the information that he has very generously compiled and offered there.&lt;p&gt;
&lt;p&gt;One of the items Gary has on the site is his Install scripts (http://stsadm.blogspot.com/2008/03/sample-install-script.html) which creates a Kerberos based 
MOSS farm, including creating and configuring the SSP and search, a portal web application, a mysites web application and a team sites web application. &lt;/p&gt;
&lt;p&gt;This is all achieved with batch files that cal PSCONFIG and STSADM commands, with a few of his own custom STSADM commands being used – very helpfully, these commands are provided as a WSP which is installed as a part of the farm creation scripts.  Very neat.&lt;/p&gt;
&lt;p&gt;These scripts follow Microsoft's "Plan for Administrative and Service Accounts (Office SharePoint Server): Least-Privilege Admin Requirements when using Domain Accounts" (http://technet.microsoft.com/en-us/library/cc263445.aspx ).&lt;/p&gt;
&lt;p&gt;I thought I would quickly go through the steps I followed to build my development vm using these scripts (note: these aren’t a comprehensive set of steps, for example I don’t indicate when I performed Windows updates and took vm snapshot’s etc., but rather cover the main items that must be completed in order to successfully create a Kerberos authenticated farm).&lt;/p&gt;
&lt;p&gt;In order to enable Kerberos, many accounts used during the install process require Service Principal Name’s (SPN’s), and being entrusted to delegate authority.  To make these changes, you require access to the ADSI Edit MMC snap-in.  Instructions on how to install this if it is not available on the machine can be found at http://technet.microsoft.com/en-us/library/cc773354(WS.10).aspx &lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;b&gt;To Create an SPN&lt;/b&gt;&lt;/p&gt;
1. Log on to your Active Directory domain controller using the credentials of a user that has domain administrative permissions.&lt;br /&gt;
2. In the Run dialog box, type ADSIEDIT.MSC.&lt;br /&gt;
3. In the management console dialog box, expand the domain container folder.&lt;br /&gt;
4. Expand the container folder containing user accounts, for example CN=Users.&lt;br /&gt;
5. Locate the container for the SQL Server Service account, for example CN=mosssqlsvc.&lt;br /&gt;
6. Right-click this account, and then click Properties.&lt;br /&gt;
7. Scroll down the list of properties in the SQL Server Service account dialog box until you find servicePrincipalName. &lt;br /&gt;
8. Select the servicePrincipalName property and click Edit.&lt;br /&gt;
9. In the Value to Add field, in the Multi-Valued String Editor dialog box,enter the Service Principal Name string – which takes the form of: {Protocol}/{host and FQDN}:{Port}, e.g. “MSSQLSvc/mosssql:1433” or “HTTP/intranet.development.com” * – and click Add.&lt;br /&gt;
10. Click OK on the Multi-Valued String Editor dialog box, and then click OK on the properties dialog box for the SQL Server service account.&lt;br /&gt;

&lt;p&gt;*One little “gotcha” that you may need to be aware of when creating a Kerberos authenticated farm is that SharePoint 2007 only supports Kerberos web applications running of the default ports.  This is why I have not had to supply port numbers in the SPNs used by the application pool accounts.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;b&gt;Setting an Account as Entrusted to Delegate Authority&lt;/b&gt;&lt;/p&gt;

1. Start the “Active Directory Users and Computers” MMC snap-in.&lt;br /&gt;
2. In the left pane, click Users.&lt;br /&gt;
3. In the right pane, right-click the name of the user account, and then click Properties.&lt;br /&gt;
4. Click the Account tab, under Account Options, click to select the Account is trusted for delegation check box, and then click OK.&lt;br /&gt;

&lt;p&gt;Ok, so to create my environment, the steps I followed were (note: these steps assume that the current account being used to perform the installation is a member of the local administrators group):&lt;/p&gt;

1. Create the vm, install the operating system and activate the Application Server, Domain Controller and DNS roles (I cover these steps in a bit more detail in this post: http://suguk.org/blogs/the_moss-pit/archive/2008/12/22/16362.aspx).&lt;br /&gt;
2. Create the SQL Server service account (svc-sqlsvr) as a domain account, give it an SPN of MSSQLSvc/{host and FQDN}:1433, and enable it for delegation.&lt;br /&gt;
3. Install SQL Server and all related SP’s.&lt;br /&gt;
4. Grant the current account performing the install sys_admin privileges on the database.&lt;br /&gt;
5. Create the following domain accounts, setting the one’s with SPN’s to be trusted for delegation (format: Account Name -- SPN -- Comments):&lt;br /&gt;&lt;br /&gt;

spadmin -- [none] -- Used to generate emails from the farm to users.  Requires an email address to be specified like no-reply@{email}.{server}&lt;br /&gt;&lt;br /&gt;
spfarm -- HTTP/{host &amp; FQDN}:{Admin port} -- [no comment]&lt;br /&gt;&lt;br /&gt;
sspapppool -- HTTP/sspadmin.{FQDN} -- Should not be a member of the Administrators group on any computer in the server farm.&lt;br /&gt;&lt;br /&gt;
sspsvc -- [none] -- This account should not be a member of the Administrators group on any computer in the server farm.&lt;br /&gt;&lt;br /&gt;
sspsearch -- [none] -- Should not be a member of the Farm Administrators group.&lt;br /&gt;&lt;br /&gt;
sspcontent -- [none] -- Should not be a member of the Farm Administrators group.&lt;br /&gt;&lt;br /&gt;
sspuserprofilesvc -- [none] -- Requires read access to the directory service, and Manage User Profiles personalization services permission.&lt;br /&gt;&lt;br /&gt;
sspexcelsvc	 -- [none] -- used for running excel services on the ssp&lt;br /&gt;&lt;br /&gt;
sphelpsearch -- [none] -- Should not be a member of the Farm Administrators group.&lt;br /&gt;&lt;br /&gt;
spcontentsearch -- [none] -- Should not be a member of the Farm Administrators group.&lt;br /&gt;&lt;br /&gt;
spportalapppool -- HTTP/portal.{FQDN} -- Should not be a member of the Administrators group on any computer in the server farm.&lt;br /&gt;&lt;br /&gt;
spmysitesapppool -- HTTP/mysites.{FQDN} -- Should not be a member of the Administrators group on any computer in the server farm.&lt;br /&gt;&lt;br /&gt;
spteamsiteapppool -- HTTP/teams.{FQDN} -- Should not be a member of the Administrators group on any computer in the server farm.&lt;br /&gt;&lt;br /&gt;
siteowner1 -- [none] -- Should be modified here and in the scripts to be a sensible account for your env.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;

6. Install MOSS, but don’t run the config wizard.&lt;br /&gt;
7. Install the MOSS infrastructure update (this is required to enable Kerberos), and the service packs.&lt;br /&gt;
8. Create your DNS entries to support the four web sites (sspadmin, portal, mysites, teams)&lt;br /&gt;
9. Run the Gary Lapointe’s farm creation scripts.&lt;br /&gt;
&lt;p&gt;I then found a few more things I had to do to complete the farm install:&lt;/p&gt;
&lt;p&gt;- configure the index server in central admin (Operations-&gt;Services on server-&gt;Search Indexing-&gt;Office SharePoint Server Search&lt;/p&gt;
&lt;p&gt;- configure the default access account (SSP Admin-&gt;Search Administration-&gt;Default Content Access account) &lt;/p&gt;
&lt;p&gt;Fix up the license type reset that happens when you install SP2 (CentralAdmin-&gt;Operations-&gt;Convert License Type)
&lt;p&gt;- Go over the rest of the settings in the SSP and Central Admin to make sure they suit your needs (eg. crawl schedules and rules, profile import sched's, usage analytics etc.)&lt;/p&gt;
&lt;p&gt;Following this process established the SharePoint farm which included the creating Central Admin, the SSP and three web applications.&lt;/p&gt;&lt;img src="http://suguk.org/aggbug.aspx?PostID=23354" width="1" height="1"&gt;</description></item><item><title>Squashing the SharePoint's SPHttpApplication Memory Leak</title><link>http://suguk.org/blogs/the_moss-pit/archive/2010/02/17/22752.aspx</link><pubDate>Wed, 17 Feb 2010 14:28:00 GMT</pubDate><guid isPermaLink="false">19180fc3-a95d-4057-992e-fee77d73db0e:22752</guid><dc:creator>AussieNigel</dc:creator><slash:comments>2</slash:comments><comments>http://suguk.org/blogs/the_moss-pit/comments/22752.aspx</comments><wfw:commentRss>http://suguk.org/blogs/the_moss-pit/commentrss.aspx?PostID=22752</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Verdana size=2&gt;A (rather major) memory leak has been found in SharePoint, caused by the failure of SPHttpApplication objects to be properly cleaned up - read all about it in Todd Carter's great post The &lt;A href="http://todd-carter.com/post/2010/02/08/SharePointe28099s-Sasquatch-Memory-Leak.aspx"&gt;Sharepoint Sasquatch Memory Leak&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;I have quickly whipped up a WSP that implements Todd's fix and thought I would attach it here for anyone else who might find it useful.  It simply deploys a DLL to the GAC which implements the classs he describes in his post.  I have done it as a WSP so that the DLL will be auto deployed to all web front-ends used by the web application it is deployed to.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;The install process is as follows:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;1) Install the wsp to the central admin solution store (using "stsadm -o addsolution -filename [filename]&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;2) From Central Admin, deploy the solution to your targeted web application.  This will deploy the SPHttpApplicationLeakFix DLL to the GAC on all the web front-ends for that web application.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;3) Go onto all the web front-ends and change the global.asax file (found at: &lt;/FONT&gt;&lt;FONT face=Verdana size=2&gt;'\InetPub\wwwroot\wss\VirtualDirectories\[Web App Dir Name]'). The two lines that need to be modifed are:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color=#0000ff size=2&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;they should be changed to:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color=#0000ff size=2&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;FONT face="Courier New" color=#0000ff size=2&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000000&gt;That's it - at this stage your sharepoint web application should still load and behave as normal, though hopefully its w3 worker process won't be consuming the huge levels of memory it was previously!&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000000&gt;A zip containing the WSP and a small readme is attached to this article.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt; &lt;/P&gt;&lt;/FONT&gt;


NOTE:

Now the update contains the wsp - apologies for the complete balls-up ;)
&lt;img src="http://suguk.org/aggbug.aspx?PostID=22752" width="1" height="1"&gt;</description><enclosure url="http://suguk.org/blogs/the_moss-pit/attachment/22752.ashx" length="3130" type="application/x-zip-compressed" /></item><item><title>Setting up Dev VM with Mail</title><link>http://suguk.org/blogs/the_moss-pit/archive/2010/02/07/22584.aspx</link><pubDate>Sun, 07 Feb 2010 09:07:00 GMT</pubDate><guid isPermaLink="false">19180fc3-a95d-4057-992e-fee77d73db0e:22584</guid><dc:creator>AussieNigel</dc:creator><slash:comments>0</slash:comments><comments>http://suguk.org/blogs/the_moss-pit/comments/22584.aspx</comments><wfw:commentRss>http://suguk.org/blogs/the_moss-pit/commentrss.aspx?PostID=22584</wfw:commentRss><description>Another really short bog entry - another pointer to someone elses blog!  

This is a great little walkthrough re: creating a development vm with DNS and AD and Mail -

 http://blogs.msdn.com/johnwpowell/archive/2008/07/07/walkthrough-build-a-windows-sharepoint-services-3-0-development-virtual-pc-with-sql-server-active-directory-and-e-mail.aspx

&lt;img src="http://suguk.org/aggbug.aspx?PostID=22584" width="1" height="1"&gt;</description></item><item><title>Nice blog on setting up FBA</title><link>http://suguk.org/blogs/the_moss-pit/archive/2009/11/30/21767.aspx</link><pubDate>Mon, 30 Nov 2009 03:59:00 GMT</pubDate><guid isPermaLink="false">19180fc3-a95d-4057-992e-fee77d73db0e:21767</guid><dc:creator>AussieNigel</dc:creator><slash:comments>1</slash:comments><comments>http://suguk.org/blogs/the_moss-pit/comments/21767.aspx</comments><wfw:commentRss>http://suguk.org/blogs/the_moss-pit/commentrss.aspx?PostID=21767</wfw:commentRss><description>Havent blogged for ages - must get back into it soon.  Anyways, here is a nice blog entry on setting up FBA for SharePoint 2007 using IIS7: http://blog.summitcloud.com/2009/10/enable-forms-based-authentication-for-sharepoint/&lt;img src="http://suguk.org/aggbug.aspx?PostID=21767" width="1" height="1"&gt;</description></item><item><title>SPUtility - worth a look</title><link>http://suguk.org/blogs/the_moss-pit/archive/2009/01/14/16601.aspx</link><pubDate>Wed, 14 Jan 2009 16:24:00 GMT</pubDate><guid isPermaLink="false">19180fc3-a95d-4057-992e-fee77d73db0e:16601</guid><dc:creator>AussieNigel</dc:creator><slash:comments>0</slash:comments><comments>http://suguk.org/blogs/the_moss-pit/comments/16601.aspx</comments><wfw:commentRss>http://suguk.org/blogs/the_moss-pit/commentrss.aspx?PostID=16601</wfw:commentRss><description>&lt;div&gt;&lt;font size="2" face="Verdana"&gt;I'd seen references to SPUtility before, and probably even used the 
object when basing code of blog posts I'd found on the net, but inspiration 
struct me the other day, and I decided to look it up in the SDK.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;It is a static object that contains a number of useful functions - it also 
contains a number of obsolete functions, and some downright weird ones (like 
SPUtility.HideTaiwan and SPUtility.IsEastAsia strike me as ones that won't be 
widely used).&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;To access the object, you need to add the following using statement:&lt;/font&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Courier New"&gt;&lt;font color="#0000ff"&gt;using&lt;/font&gt; 
Microsoft.SharePoint.Utilities;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;I had a quick go through the SDK, an the following are what strikes me as 
some of the more useful functions this object provides (note, I havent used all 
of these yet, just went through the SDK then googled the functions I thought 
sounded interesting):&lt;/font&gt;&lt;/div&gt;
&lt;ul&gt;&lt;li&gt;&lt;font size="2" face="Verdana"&gt;&lt;b&gt;SPUtility.FormatDate&lt;/b&gt;&lt;br&gt;&lt;br&gt;Allows you to format a given date to any of the 
SPDateFormat types&lt;/font&gt;&lt;br&gt;&lt;br&gt;&lt;font size="2" color="#2b91af"&gt;
&lt;/font&gt;&lt;p&gt;&lt;font size="2" color="#2b91af" face="Courier New"&gt;DateTime&lt;/font&gt;&lt;font size="2" face="Courier New"&gt; curDate = &lt;/font&gt;&lt;font size="2" color="#2b91af" face="Courier New"&gt;DateTime&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;.Now();&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#2b91af" face="Courier New"&gt;DateTime&lt;/font&gt;&lt;font size="2" face="Courier New"&gt; regionDate = 
web.RegionalSettings.TimeZone.UTCToLocalTime(web.ParentWeb.RegionalSettings.TimeZone.LocalTimeToUTC(curDate));&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;return&lt;/font&gt;&lt;font size="2" face="Courier New"&gt; &lt;/font&gt;&lt;font size="2" color="#2b91af" face="Courier New"&gt;Convert&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;.ToDateTime(&lt;/font&gt;&lt;font size="2" color="#2b91af" face="Courier New"&gt;SPUtility&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;.FormatDate(web, regionDate, &lt;/font&gt;&lt;font size="2" color="#2b91af" face="Courier New"&gt;SPDateFormat&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;.ISO8601));&lt;/font&gt;&lt;/p&gt;&lt;br&gt;&lt;br&gt;
&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Verdana"&gt;&lt;b&gt;Get the 12-Hive filesystem path&lt;/b&gt;&lt;br&gt;&lt;br&gt;Returns the filesystem path for the 
12-Hive, or any of the folders beneath it.  This is typically (though not 
always) going to be C:\Program Files\Common Files\Microsoft Shared\web server 
extensions\12&lt;br&gt;&lt;/font&gt;&lt;br&gt;&lt;font size="2" color="#008000"&gt;
&lt;/font&gt;&lt;p&gt;&lt;font size="2" color="#008000" face="Courier New"&gt;//Get path to features directory&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#008000" face="Courier New"&gt;//Would 
typically return "C:\Program Files\Common Files\Microsoft Shared\web server 
extensions\12\TEMPLATE\FEATURES"&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;string&lt;/font&gt;&lt;font size="2" face="Courier New"&gt; featurePath = &lt;/font&gt;&lt;font size="2" color="#2b91af" face="Courier New"&gt;SPUtility&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;.GetGenericSetupPath(&lt;/font&gt;&lt;font size="2" color="#a31515" face="Courier New"&gt;"template\\features"&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;);&lt;/font&gt;&lt;/p&gt;&lt;br&gt;
&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Verdana"&gt;&lt;b&gt;Get Full (absolute) URL&lt;/b&gt;&lt;br&gt;&lt;br&gt;Converts a relative Url into an absolute 
Url&lt;/font&gt;&lt;br&gt;&lt;br&gt;&lt;font size="2" color="#008000"&gt;
&lt;/font&gt;&lt;p&gt;&lt;font size="2" color="#008000" face="Courier New"&gt;//Get url to list item&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#2b91af" face="Courier New"&gt;SPListItem&lt;/font&gt;&lt;font size="2" face="Courier New"&gt; item = spList.Items[1];&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;string&lt;/font&gt;&lt;font size="2" face="Courier New"&gt; itemUrl = &lt;/font&gt;&lt;font size="2" color="#2b91af" face="Courier New"&gt;SPUtility&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;.GetFullUrl(spSite, 
item.Url);&lt;/font&gt;&lt;/p&gt;&lt;br&gt;
&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Verdana"&gt;&lt;b&gt;Redirect to page&lt;/b&gt;&lt;br&gt;&lt;br&gt;Send a HTTP redirect to the client's 
browser&lt;/font&gt;&lt;br&gt;&lt;br&gt;&lt;font size="2" color="#008000"&gt;
&lt;/font&gt;&lt;p&gt;&lt;font size="2" color="#008000" face="Courier New"&gt;//Redirect to specified page, adding querystring&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;string&lt;/font&gt;&lt;font size="2" face="Courier New"&gt; url = &lt;/font&gt;&lt;font size="2" color="#a31515" face="Courier New"&gt;"http://portal/TestResults/Pages/results.aspx"&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;string&lt;/font&gt;&lt;font size="2" face="Courier New"&gt; queryString = 
&lt;/font&gt;&lt;font size="2" color="#a31515" face="Courier New"&gt;"successflag=passed"&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;;&lt;br&gt;&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#2b91af" face="Courier New"&gt;SPUtility&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;.Redirect(url, &lt;/font&gt;&lt;font size="2" color="#2b91af" face="Courier New"&gt;SPRedirectFlags&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;.Default, Context, 
queryString);&lt;/font&gt;&lt;/p&gt;&lt;br&gt;
&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Verdana"&gt;&lt;b&gt;Send email&lt;/b&gt;&lt;br&gt;&lt;br&gt;Lets you send an email from the context of the given 
SPWeb&lt;br&gt;&lt;/font&gt;&lt;br&gt;&lt;font size="2" color="#008000"&gt;
&lt;/font&gt;&lt;p&gt;&lt;font size="2" color="#008000" face="Courier New"&gt;//Send email from current SPWeb&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#2b91af" face="Courier New"&gt;SPWeb&lt;/font&gt;&lt;font size="2" face="Courier New"&gt; web = &lt;/font&gt;&lt;font size="2" color="#2b91af" face="Courier New"&gt;SPContext&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;.Current.Site.OpenWeb();&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;string&lt;/font&gt;&lt;font size="2" face="Courier New"&gt; subject = &lt;/font&gt;&lt;font size="2" color="#a31515" face="Courier New"&gt;"Email from the "&lt;/font&gt;&lt;font size="2" face="Courier New"&gt; + web.Title + 
&lt;/font&gt;&lt;font size="2" color="#a31515" face="Courier New"&gt;" web"&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;;&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;string&lt;/font&gt;&lt;font size="2" face="Courier New"&gt; body = &lt;/font&gt;&lt;font size="2" color="#a31515" face="Courier New"&gt;"The body of the email"&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" color="#2b91af" face="Courier New"&gt;SPUtility&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;.SendEmail(web, &lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;false&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;, &lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;false&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;, 
&lt;/font&gt;&lt;font size="2" color="#a31515" face="Courier New"&gt;"someone@somewhere.com"&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;, 
subject, body);&lt;/font&gt;&lt;/p&gt;&lt;br&gt;
&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Verdana"&gt;&lt;b&gt;Transfer to SharePoint success/error page&lt;/b&gt;&lt;br&gt;&lt;br&gt;Allows you to transfer the 
browser to the ootb error and success pages&lt;br&gt;&lt;/font&gt;&lt;br&gt;&lt;font size="2" color="#008000"&gt;
&lt;/font&gt;&lt;p&gt;&lt;font size="2" color="#008000" face="Courier New"&gt;//Transfer to Error Page&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#2b91af" face="Courier New"&gt;SPUtility&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;.TransferToErrorPage(ex.Message);&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" color="#008000" face="Courier New"&gt;//Transfer to success page, and specify url 
to move onto after "Ok" clicked&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#2b91af" face="Courier New"&gt;SPUtility&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;.TransferToSuccessPage(&lt;/font&gt;&lt;font size="2" color="#a31515" face="Courier New"&gt;"Operation was completed"&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;, &lt;/font&gt;&lt;font size="2" color="#a31515" face="Courier New"&gt;@"/Docs/default.aspx"&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;, &lt;/font&gt;&lt;font size="2" color="#a31515" face="Courier New"&gt;""&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;, &lt;/font&gt;&lt;font size="2" color="#a31515" face="Courier New"&gt;""&lt;/font&gt;&lt;font size="2"&gt;&lt;font size="3" face="Courier New"&gt;&lt;font size="2"&gt;);&lt;/font&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;font size="2" face="Verdana"&gt;There are a bunch of others on there, and although they are not really very 
well documented, they are certainly worth a look through.&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;img src="http://suguk.org/aggbug.aspx?PostID=16601" width="1" height="1"&gt;</description></item><item><title>A catch using SPSecurity.RunWithElevatedPrivileges</title><link>http://suguk.org/blogs/the_moss-pit/archive/2009/01/05/16426.aspx</link><pubDate>Mon, 05 Jan 2009 16:46:00 GMT</pubDate><guid isPermaLink="false">19180fc3-a95d-4057-992e-fee77d73db0e:16426</guid><dc:creator>AussieNigel</dc:creator><slash:comments>3</slash:comments><comments>http://suguk.org/blogs/the_moss-pit/comments/16426.aspx</comments><wfw:commentRss>http://suguk.org/blogs/the_moss-pit/commentrss.aspx?PostID=16426</wfw:commentRss><description>&lt;div&gt;&lt;font size="2" face="Verdana"&gt;In a 
Page Visitor Tracking web part I have been writing, I use the &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsecurity.runwithelevatedprivileges.aspx"&gt;&lt;strong&gt;SPSecurity.RunWithElevatedPrivileges&lt;/strong&gt;&lt;/a&gt; 
function to add or update a line in a Visitor Tracking list on the current 
site.  The idea being that not all visitors to the page will have the rights to 
write to this list, so some level of impersonation is needed.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;Frustratingly, even though I had used this function to elevate the 
privileges of the current user, I was still getting an "Access Denied" message 
when running the functionality under my test user.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;After a bit of searching on the net (great entry by Daniel Larson - &lt;a href="http://daniellarson.spaces.live.com/blog/cns%21D3543C5837291E93%21927.entry?sa=486500840"&gt;&lt;strong&gt;http://daniellarson.spaces.live.com/blog/cns!D3543C5837291E93!927.entry?sa=486500840&lt;/strong&gt;&lt;/a&gt;), 
I determined that the problem was that I was getting my reference to the list 
whilst the code was still running under the current users context, and not the 
elevated user.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;e.g. (Note, this code sample has been cut down a great deal to illustrate 
the point - no "try...catch" blocks, for example.  It should be used only as a guide, and 
not copied to be used as is)&lt;/font&gt;&lt;/div&gt;
&lt;div&gt; &lt;br&gt;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -&lt;br&gt;&lt;br&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face="Courier New"&gt;&lt;font size="2" color="#0000ff"&gt;protected&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;override&lt;/font&gt;&lt;font size="2"&gt; 
&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;void&lt;/font&gt;&lt;/font&gt;&lt;font size="2" face="Courier New"&gt; CreateChildControls()&lt;br&gt;{&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#008000" face="Courier New"&gt;    //Get the current web&lt;br&gt;    &lt;/font&gt;&lt;font size="2"&gt;&lt;font face="Courier New"&gt;SPWeb web = SPControl.GetContextWeb(Context);&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;&lt;font size="2" color="#008000"&gt;    //Get the list 
to record visits&lt;br&gt;    &lt;/font&gt;&lt;font size="2"&gt;visList = 
web.Lists[_visitorList];&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;font face="Courier New"&gt;    &lt;/font&gt;&lt;font color="#008000" face="Courier New"&gt;//See if this user already exists in list&lt;br&gt;    
&lt;/font&gt;&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;_existItemId = 
GetVisitorItemId(visList);&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;    &lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color="#008000"&gt;&lt;font size="2"&gt;//If not in list, add them&lt;/font&gt;&lt;br&gt;    &lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;if&lt;/font&gt; (_existItemId == 0)&lt;/font&gt;&lt;br&gt;    &lt;font size="2"&gt;{&lt;/font&gt;&lt;br&gt;        &lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color="#008000"&gt;&lt;font size="2"&gt;//Run the AddCurrentUserToList function with elevated 
priv's&lt;/font&gt;&lt;br&gt;       &lt;/font&gt;&lt;font size="2"&gt;SPSecurity.CodeToRunElevated 
elevatedAddCurrentUserToList = &lt;font color="#0000ff"&gt;new&lt;/font&gt; 
SPSecurity.CodeToRunElevated(AddCurrentUserToList);&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;        &lt;font size="2"&gt;SPSecurity.RunWithElevatedPrivileges(elevatedAddCurrentUserToList);&lt;/font&gt;&lt;br&gt;    
&lt;font size="2"&gt;}&lt;/font&gt;&lt;br&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color="#0000ff"&gt;&lt;font size="2"&gt;   else&lt;/font&gt;&lt;br&gt;    &lt;/font&gt;&lt;font size="2"&gt;{&lt;/font&gt;&lt;br&gt;        &lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color="#008000"&gt;&lt;font size="2"&gt;//Run the AddCurrentUserToList function with elevated 
priv's&lt;/font&gt;&lt;br&gt;        &lt;/font&gt;&lt;font size="2"&gt;SPSecurity.CodeToRunElevated 
elevatedIncrementNumberOfVisits = &lt;font color="#0000ff"&gt;new&lt;/font&gt; 
SPSecurity.CodeToRunElevated(IncrementNumberOfVisits);&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;        &lt;font size="2"&gt;SPSecurity.RunWithElevatedPrivileges(elevatedIncrementNumberOfVisits);&lt;/font&gt;&lt;br&gt;    
&lt;font size="2"&gt;}&lt;/font&gt;&lt;br&gt;&lt;font size="2"&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;
&lt;/font&gt;&lt;/font&gt;&lt;p&gt;&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;&lt;br&gt;&lt;font face="Courier New"&gt;private&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt; 
&lt;font color="#0000ff"&gt;void&lt;/font&gt; AddCurrentUserToList()&lt;/font&gt;&lt;/font&gt;&lt;br&gt;&lt;font face="Courier New"&gt;&lt;font size="2"&gt;{&lt;/font&gt;&lt;br&gt;    &lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color="#008000"&gt;&lt;font size="2"&gt;//Create new 
ListItem&lt;/font&gt;&lt;br&gt;    &lt;/font&gt;&lt;font size="2"&gt;SPListItemCollection items = 
visList.Items;&lt;/font&gt;&lt;br&gt;    &lt;font size="2"&gt;SPListItem newItem = 
items.Add();&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;    &lt;font color="#008000"&gt;&lt;font size="2"&gt;//Set field 
values for new ListItem&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;&lt;font color="#008000"&gt;    &lt;font size="2"&gt;//Update 
Item&lt;/font&gt;&lt;/font&gt;&lt;br&gt;    &lt;font size="2"&gt;newItem.Update();&lt;/font&gt;&lt;br&gt;&lt;font size="2"&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;
&lt;/font&gt;&lt;/font&gt;&lt;p&gt;&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;&lt;br&gt;&lt;font face="Courier New"&gt;private&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt; 
&lt;font color="#0000ff"&gt;void&lt;/font&gt; IncrementNumberOfVisits()&lt;/font&gt;&lt;/font&gt;&lt;br&gt;&lt;font face="Courier New"&gt;&lt;font size="2"&gt;{&lt;/font&gt;&lt;br&gt;    &lt;font color="#008000"&gt;&lt;font size="2"&gt;//Get the ListItem to update&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font color="#008000"&gt;&lt;font face="Courier New"&gt;    &lt;font size="2"&gt;//Increment the 
number of visits&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;    &lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color="#008000"&gt;&lt;font size="2"&gt;//Update the item&lt;/font&gt;&lt;br&gt;    &lt;/font&gt;&lt;font size="2"&gt;updateItem.Update();&lt;/font&gt;&lt;br&gt;&lt;font size="2"&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;/div&gt;
&lt;div&gt; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -&lt;br&gt;
&lt;br&gt;&lt;br&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;Because of this, I changed my code so that I made a new reference to the 
SPWeb in the elevated code block, and obtained a new reference to the 
list:&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;br&gt;&lt;br&gt;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -&lt;br&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2"&gt;
&lt;/font&gt;&lt;p&gt;&lt;font face="Courier New"&gt;&lt;font size="2" color="#0000ff"&gt;protected&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;override&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;void&lt;/font&gt;&lt;/font&gt;&lt;font size="2" face="Courier New"&gt; 
CreateChildControls()&lt;br&gt;{&lt;br&gt;    &lt;/font&gt;&lt;font size="2" color="#008000" face="Courier New"&gt;//Get the current web&lt;br&gt;    &lt;/font&gt;&lt;font size="2" face="Courier New"&gt;SPWeb 
web = SPControl.GetContextWeb(Context);&lt;br&gt;    _curWeb = web.Url;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;&lt;font size="2"&gt;    SPList visList = &lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;null&lt;/font&gt;&lt;font size="2"&gt;;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;font face="Courier New"&gt;    &lt;/font&gt;&lt;font color="#008000" face="Courier New"&gt;//Get the list to record visits&lt;br&gt;    &lt;/font&gt;&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;visList = web.Lists[_visitorList];&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;    &lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color="#008000"&gt;&lt;font size="2"&gt;//See if this user already exists in 
list&lt;/font&gt;&lt;br&gt;    &lt;/font&gt;&lt;font size="2"&gt;_existItemId = 
GetVisitorItemId(visList);&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;    &lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color="#008000"&gt;&lt;font size="2"&gt;//If not in list, add them&lt;/font&gt;&lt;br&gt;    &lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;if&lt;/font&gt; (_existItemId == 0)&lt;/font&gt;&lt;br&gt;    &lt;font size="2"&gt;{&lt;/font&gt;&lt;br&gt;        &lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color="#008000"&gt;&lt;font size="2"&gt;//Run the AddCurrentUserToList function with elevated 
priv's&lt;/font&gt;&lt;br&gt;        &lt;/font&gt;&lt;font size="2"&gt;SPSecurity.CodeToRunElevated 
elevatedAddCurrentUserToList = &lt;font color="#0000ff"&gt;new&lt;/font&gt; 
SPSecurity.CodeToRunElevated(AddCurrentUserToList);&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;        &lt;font size="2"&gt;SPSecurity.RunWithElevatedPrivileges(elevatedAddCurrentUserToList);&lt;/font&gt;&lt;br&gt;    
&lt;font size="2"&gt;}&lt;/font&gt;&lt;br&gt;    &lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color="#0000ff"&gt;&lt;font size="2"&gt;else&lt;/font&gt;&lt;br&gt;    &lt;/font&gt;&lt;font size="2"&gt;{&lt;/font&gt;&lt;br&gt;        &lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color="#008000"&gt;&lt;font size="2"&gt;//Run the AddCurrentUserToList function with elevated 
priv's&lt;/font&gt;&lt;br&gt;        &lt;/font&gt;&lt;font size="2"&gt;SPSecurity.CodeToRunElevated 
elevatedIncrementNumberOfVisits = &lt;font color="#0000ff"&gt;new&lt;/font&gt; 
SPSecurity.CodeToRunElevated(IncrementNumberOfVisits);&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;        &lt;font size="2"&gt;SPSecurity.RunWithElevatedPrivileges(elevatedIncrementNumberOfVisits);&lt;/font&gt;&lt;br&gt;    
&lt;font size="2"&gt;}&lt;/font&gt;&lt;br&gt;&lt;font size="2"&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;
&lt;/font&gt;&lt;/font&gt;&lt;p&gt;&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;&lt;br&gt;&lt;font face="Courier New"&gt;private&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt; 
&lt;font color="#0000ff"&gt;void&lt;/font&gt; AddCurrentUserToList()&lt;/font&gt;&lt;/font&gt;&lt;br&gt;&lt;font face="Courier New"&gt;&lt;font size="2"&gt;{&lt;/font&gt;&lt;br&gt;    &lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color="#008000"&gt;&lt;font size="2"&gt;//Get list&lt;/font&gt;&lt;br&gt;    
&lt;/font&gt;&lt;font size="2"&gt;SPSite site = &lt;font color="#0000ff"&gt;new&lt;/font&gt; 
SPSite(_curWeb);&lt;/font&gt;&lt;br&gt;    &lt;font size="2"&gt;SPWeb web = 
site.OpenWeb();&lt;/font&gt;&lt;br&gt;    &lt;font size="2"&gt;SPList visList = 
web.Lists[_visitorList];&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;    &lt;font size="2"&gt;web.AllowUnsafeUpdates = &lt;font color="#0000ff"&gt;true&lt;/font&gt;;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Courier New"&gt;     &lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color="#008000"&gt;&lt;font size="2"&gt;//Create new ListItem&lt;br&gt;     &lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;SPListItemCollection items = visList.Items;&lt;/font&gt;&lt;br&gt;    &lt;font size="2"&gt;SPListItem newItem = items.Add();&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;    &lt;font color="#008000"&gt;&lt;font size="2"&gt;//Set field 
values for new ListItem&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;&lt;font color="#008000"&gt;    &lt;font size="2"&gt;//Update 
Item&lt;/font&gt;&lt;/font&gt;&lt;br&gt;    &lt;font size="2"&gt;newItem.Update();&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;    &lt;font size="2"&gt;web.AllowUnsafeUpdates = &lt;font color="#0000ff"&gt;false&lt;/font&gt;;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;    &lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color="#008000"&gt;&lt;font size="2"&gt;//Cleanup&lt;/font&gt;&lt;br&gt;    &lt;/font&gt;&lt;font size="2"&gt;web.Dispose();&lt;/font&gt;&lt;br&gt;    &lt;font size="2"&gt;site.Dispose();&lt;/font&gt;&lt;br&gt;&lt;font size="2"&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;private&lt;/font&gt; 
&lt;font color="#0000ff"&gt;void&lt;/font&gt; IncrementNumberOfVisits()&lt;/font&gt;&lt;br&gt;&lt;font size="2"&gt;{&lt;/font&gt;&lt;br&gt;    &lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color="#008000"&gt;&lt;font size="2"&gt;//Get list&lt;/font&gt;&lt;br&gt;    &lt;/font&gt;&lt;font size="2"&gt;SPSite site = &lt;font color="#0000ff"&gt;new&lt;/font&gt; SPSite(_curWeb);&lt;/font&gt;&lt;br&gt;    &lt;font size="2"&gt;SPWeb web = 
site.OpenWeb();&lt;/font&gt;&lt;br&gt;    &lt;font size="2"&gt;SPList visList = 
web.Lists[_visitorList];&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Courier New"&gt;    web.AllowUnsafeUpdates = &lt;font color="#0000ff"&gt;true&lt;/font&gt;;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;    &lt;font color="#008000"&gt;&lt;font size="2"&gt;//Get the 
ListItem to update&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font color="#008000"&gt;&lt;font face="Courier New"&gt;&lt;font size="2"&gt;    &lt;/font&gt;&lt;font size="2"&gt;//Increment the number of visits&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;    &lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color="#008000"&gt;&lt;font size="2"&gt;//Update the item&lt;/font&gt;&lt;br&gt;    &lt;/font&gt;&lt;font size="2"&gt;updateItem.Update();&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;    &lt;font size="2"&gt;web.AllowUnsafeUpdates = &lt;font color="#0000ff"&gt;false&lt;/font&gt;;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;    &lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color="#008000"&gt;&lt;font size="2"&gt;//Cleanup&lt;/font&gt;&lt;br&gt;    &lt;/font&gt;&lt;font size="2"&gt;web.Dispose();&lt;/font&gt;&lt;br&gt;    &lt;font size="2"&gt;site.Dispose();&lt;/font&gt;&lt;br&gt;&lt;font size="2"&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;/div&gt;
&lt;div&gt; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -&lt;br&gt;
&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;SPList's, SPWeb's etc get the identity of the user context they are created 
under associated with them for their entire lifetime.  Like most things, seems 
obvious once you understand it. &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;To get around this, I no longer use the SPList globally, but instead keep 
the URL of the web globally, and use this in the elevated code blocks to derive 
an SPSite, SPWeb and finally the required SPList.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;Important to note that this as the SPWeb that I create in the elevated code 
block is a different SPWeb to what I am using outside this block (it has the 
SHAREPOINT\Security identity associated with it, not the current users) it can 
(and should) safely disposed of from within this block.&lt;br&gt;&lt;br&gt;-----------------------------------------------------------&lt;br&gt;&lt;br&gt;&lt;b&gt;&lt;font color="#ff0000"&gt;UPDATE:&lt;/font&gt;&lt;/b&gt;&lt;font color="#ff0000"&gt;&lt;font color="#000000"&gt;  As can be seen in the comments below, &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2" face="Verdana"&gt;Keith Dahlby has posted a much more elegant way of achieving the elevation of privileges by using the site's token.
&lt;br&gt;&lt;br&gt;I have changed my code to follow this (and incorporated the
functionality in my SharePoint.Common library) and recommend reading
his article - see &lt;a rel="nofollow" target="_new" href="http://solutionizing.net/2009/01/06/elegant-spsite-elevation/"&gt;http://solutionizing.net/2009/01/06/elegant-spsite-elevation/&lt;/a&gt;&lt;br&gt;&lt;br&gt;Keep up the good work Keith!
&lt;/font&gt;


&lt;font size="2" face="Verdana"&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;/font&gt;&lt;/div&gt;&lt;img src="http://suguk.org/aggbug.aspx?PostID=16426" width="1" height="1"&gt;</description></item><item><title>Creating a SharePoint Development Virtual Machine - Part II</title><link>http://suguk.org/blogs/the_moss-pit/archive/2008/12/24/16381.aspx</link><pubDate>Wed, 24 Dec 2008 14:21:00 GMT</pubDate><guid isPermaLink="false">19180fc3-a95d-4057-992e-fee77d73db0e:16381</guid><dc:creator>AussieNigel</dc:creator><slash:comments>3</slash:comments><comments>http://suguk.org/blogs/the_moss-pit/comments/16381.aspx</comments><wfw:commentRss>http://suguk.org/blogs/the_moss-pit/commentrss.aspx?PostID=16381</wfw:commentRss><description>&lt;div class="ExternalClassC76121D2502545C6A6CCFA9708167E03"&gt;&lt;font size="2" face="Verdana"&gt;The thought 
occured to me that my previous article on this subject detailed how I go about 
building a nice clean development environment, but not what the next steps were, 
i.e. getting a working copy of the production web application on that 
environment.  Hopefully, this article will show you how.&lt;/font&gt;&lt;/div&gt;
&lt;div class="ExternalClassC76121D2502545C6A6CCFA9708167E03"&gt;&lt;font size="2" face="Verdana"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div class="ExternalClassC76121D2502545C6A6CCFA9708167E03"&gt;&lt;font size="2" face="Verdana"&gt;So, assuming you have 
got a vm which has SharePoint installed on it, but not really configured, and 
with no web apps (as it would be after following my previous article), the next 
steps I follow are:&lt;/font&gt;&lt;/div&gt;
&lt;div class="ExternalClassC76121D2502545C6A6CCFA9708167E03"&gt;&lt;font size="2" face="Verdana"&gt;&lt;br&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div class="ExternalClassC76121D2502545C6A6CCFA9708167E03"&gt;&lt;font size="2" face="Verdana"&gt;&lt;strong&gt;&lt;font color="#008080"&gt;DNS Enteries&lt;/font&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div class="ExternalClassC76121D2502545C6A6CCFA9708167E03"&gt;&lt;font size="2" face="Verdana"&gt;&lt;strong&gt;&lt;font color="#008080"&gt; &lt;/font&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/div&gt;&lt;font size="2" face="Verdana"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/font&gt;
&lt;div class="ExternalClassC76121D2502545C6A6CCFA9708167E03"&gt;&lt;font size="2" face="Verdana"&gt;Create some DNS host 
enteries for the web applications you are going to be creating.  In the domain's 
forward looking zone, I create the following 3 host enteries pointing to my vm's 
ip address:&lt;/font&gt;&lt;/div&gt;
&lt;ul&gt;&lt;li&gt;
&lt;div class="ExternalClassC76121D2502545C6A6CCFA9708167E03"&gt;&lt;font size="2" face="Verdana"&gt;ssp&lt;/font&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;
&lt;div class="ExternalClassC76121D2502545C6A6CCFA9708167E03"&gt;&lt;font size="2" face="Verdana"&gt;mysite&lt;/font&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;
&lt;div class="ExternalClassC76121D2502545C6A6CCFA9708167E03"&gt;&lt;font size="2" face="Verdana"&gt;moss&lt;/font&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;div class="ExternalClassC76121D2502545C6A6CCFA9708167E03"&gt;&lt;font size="2" face="Verdana"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div class="ExternalClassC76121D2502545C6A6CCFA9708167E03"&gt;&lt;font size="2" face="Verdana"&gt;&lt;br&gt;&lt;strong&gt;&lt;font color="#008080"&gt;Configure Services on Server&lt;br&gt;&lt;br&gt;&lt;/font&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/div&gt;&lt;font size="2" face="Verdana"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/font&gt;
&lt;div class="ExternalClassC76121D2502545C6A6CCFA9708167E03"&gt;&lt;font size="2" face="Verdana"&gt;Next, I complete the 
MOSS configuration by opening Central Admin (Start-&gt;All 
Programs-&gt;Microsoft Office Server-&gt;SharePoint 3.0 central Administration). 
Click on the "Operations" tab, and "Services on Server" link. &lt;/font&gt;&lt;/div&gt;
&lt;div class="ExternalClassC76121D2502545C6A6CCFA9708167E03"&gt;&lt;font size="2" face="Verdana"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div class="ExternalClassC76121D2502545C6A6CCFA9708167E03"&gt;&lt;font size="2" face="Verdana"&gt;As the development vm 
is a single machine environment, I would activate all of the services, and in 
this order (NB: you can see all available services by choosing the "Custom" 
server role):&lt;/font&gt;&lt;/div&gt;
&lt;div class="ExternalClassC76121D2502545C6A6CCFA9708167E03"&gt;
&lt;ul&gt;&lt;li&gt;&lt;font size="2" face="Verdana"&gt;Document Load Balancing&lt;br&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Verdana"&gt;Document Conversions Launcher Service  (select your vm name in the 
"Load-balancer" dropdown)&lt;br&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Verdana"&gt;Excel Calculation Services&lt;br&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Verdana"&gt;Office SharePoint Server Search  (using the svc-spssearch account)&lt;br&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Verdana"&gt;Windows SharePoint Services Search  (using the svc-spssearch account for 
both service and content access accounts)&lt;/font&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;&lt;br&gt;&lt;strong&gt;&lt;font color="#008080"&gt;Create SSP&lt;/font&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;&lt;strong&gt;&lt;/strong&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;Next step is to create a Shared Services Provider. To do this, click the 
"Shared Services Administration" in your Quicklaunch, then click the "New SSP" 
link. The resultant page asks you to specify an SSP web application and MySites 
web applciation, but also provides you with links to create these web 
apps.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;Click the create a new web app link for your ssp, and create it on port 80 
using "ssp" as your host header.  For the application pool identity, use the 
svc-spsapool account. Change the Database name to be something meaningful (like 
WSS_Content_SSP), and select your vm as the search server in the drop down.  
Repeat this process to create your Mysite web app.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;Back on the create SSP page, use the svc-spsadmin as you ssp service 
credentials (you could really create a unique account for this if you wanted 
to), and then click ok to generate your SSP.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;&lt;br&gt;&lt;strong&gt;&lt;font color="#008080"&gt;Create Web App&lt;/font&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;&lt;strong&gt;&lt;/strong&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;Time to create the web application that will eventually hold a copy of your 
prod web app.  Click the "Back to Central Admin" link in the QuickLaunch, then 
click the "Application Management" tab.  On this screen, click "Create or Extend 
a Web Application". &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;As before, create it on port 80 using "moss" as your host header.  For the 
application pool identity, use the svc-spsapool account. Change the Database 
name to be something meaningful (like WSS_Content_Moss), and select your vm as 
the search server in the drop down.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;&lt;br&gt;&lt;strong&gt;&lt;font color="#008080"&gt;Configue SSP&lt;/font&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;Click on the "SharedServices1" link in the quicklaunch to get to the setup 
screen for this SSP.  Most of the defaults will be acceptable here, with the 
only things I think you need to consider being:&lt;/font&gt;&lt;/div&gt;
&lt;ul&gt;&lt;li&gt;&lt;font size="2" face="Verdana"&gt;the time zone&lt;br&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Verdana"&gt;upload file size limit (may need to be increased)&lt;br&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Verdana"&gt;recycle bin status (ensure default values are appropriate for 
you)&lt;br&gt;&lt;/font&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;Once you "ok" this screen, you are taken into the SSP web app itself, where 
you can configure things like profile importing and search.  The things I would 
look at for my dev vm are:&lt;/font&gt;&lt;/div&gt;
&lt;ul&gt;&lt;li&gt;&lt;font size="2" face="Verdana"&gt;User Profiles - configure the profile importing so that the full import 
(weekly) and incremental import (daily) take place at an appropriate time (when 
you vm will actually be on).&lt;br&gt;&lt;br&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Verdana"&gt;Search settings - click on "Content source and crawl schedules", and then on 
the auto generated "Local Office SharePoint Server Sites" content source.  This 
should show 4 start addresses - &lt;a href="http://moss/"&gt;http://moss&lt;/a&gt;, &lt;a href="http://mysite/"&gt;http://mysite&lt;/a&gt;, &lt;a href="http://ssp/"&gt;http://ssp&lt;/a&gt; 
and sps3://mysite.  &lt;br&gt;&lt;br&gt;Click the "Create a schedule" link under the "Full 
Crawl Schedule" dropdown, and specify a weekly time for a full crawl of the 
content to be done.  This can be resource intensive, so best if you plan it for 
a time when you know your vm will be active, but you probably wont be using it 
(weekly team meetings time is ideal). &lt;br&gt;&lt;br&gt;Repeat this process for the 
incremental crawl schedule, but make it a daily crawl - I tend to make it repeat 
every 20mins.&lt;/font&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;&lt;br&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;&lt;strong&gt;&lt;font color="#008080"&gt;Backup your "Baseline" Dev SharePoint 
Farm&lt;/font&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;&lt;strong&gt;&lt;/strong&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;At this point you have a SharePoint farm on you vm that is a good clean 
baseline farm. I would recommend backing the vm up at this point, and using a 
fresh copy of it for each "production" farm copy you are going to make to 
develop against.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;&lt;br&gt;&lt;strong&gt;&lt;font color="#008080"&gt;Backup Production 
Environment&lt;/font&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;If it is small enough, I like to take a backup of the production 
environment, and install it onto my dev environment.  Often the production web 
application is too large to make a straight backup and restore viable, but you 
can usually get around this by exporting the root and a few sub sites of the 
production environment and importing them onto your dev environment.  The steps 
that follow here assume that the prod envirnment is small enough to do a backup 
and restore:&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;ul&gt;&lt;li&gt;&lt;font size="2" face="Verdana"&gt;Backup up the web app: use STSADM to backup the web app to a file with the 
command&lt;br&gt;  &lt;br&gt;        &lt;strong&gt;stsadm.exe -o backup -url  -filename &lt;br&gt;&lt;/strong&gt;        &lt;br&gt;    You can 
add a "-overwrite" flag as well, which indicates that if the file already exists 
it should be overwritten - probably not necessary for most ad hoc 
backups.&lt;br&gt;&lt;br&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Verdana"&gt;Web.Config: grab a copy of the web.config to get an custom settings and 
safecontrols&lt;br&gt;&lt;br&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Verdana"&gt;Hive-12: next, you need to grab a copy of the production's have 12 directory 
so that you pick-up any additions/customizations here.  The directory is 
(generally) found at C:\Program Files\Common Files\Microsoft Shared\web server 
extensions\12\TEMPLATE&lt;br&gt;&lt;br&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Verdana"&gt;Solutions/DLL's: last step is to add any of the customized solutions used on 
the production farm to your dev environment.  &lt;br&gt;&lt;br&gt;If you have the solution 
packages to hand then great, put them on your vm and install them using "stsadm 
-o addsolution" - this way you get them added to the dev farm's solution store 
correctly, and the web.config gets updated appropriately. &lt;br&gt;&lt;br&gt;If you don't 
have them, a dirtier way of getting the functionality across is to just copy the 
custom DLL's from the GAC and/or bin directory onto your vm, and update the 
web.config yourself.&lt;br&gt;&lt;/font&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;&lt;br&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;&lt;strong&gt;&lt;font color="#008080"&gt;Restore to Dev 
Environment&lt;/font&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;&lt;strong&gt;&lt;/strong&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;It is best to restore you prod backup over an existing site collection, so 
the first thing to do is to create a site collection in your "Moss" web 
application of the same template type used on prod (eg. publishing). Do this by 
opening Central Admin, clicking on the "Application Management" tab, and 
clicking "Create Site Collection"&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;Take a backup of the existing 12-Hive Template directory (I generally 
create a zip "TEMPLATE-orig.zip" of it in the '12' directory), and then restore 
your prod copy of this directory over the top of the existing one.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;As mentioned previously, if you have all the customizations for the 
production environment you can install and deploy them, otherwise copy the DLL's 
to the appropriate directory (generally the GAC) and manually update the 
web.config.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;Lastly, bring your vm's web.config in to line with web.config from the prod 
environment.  I would suggest doing this manually (rather then trying to copy 
one over the top of the other) as some differences may be acceptable (or even 
necessary).  Areas to pay close attention to include:&lt;/font&gt;&lt;/div&gt;
&lt;ul&gt;&lt;li&gt;&lt;font size="2" face="Verdana"&gt;Safe Controls&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Verdana"&gt;Any additional custom ConfigSections&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Verdana"&gt;Custom Errors section&lt;/font&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;font size="2" face="Verdana"&gt; &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Verdana"&gt;And thats it - hopefully now you should have a replica of your prod 
environment on your vm, ready for you to start developing against.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Verdana"&gt; &lt;/font&gt;&lt;/p&gt;&lt;img src="http://suguk.org/aggbug.aspx?PostID=16381" width="1" height="1"&gt;</description></item><item><title>Creating a SharePoint Development Virtual Machine</title><link>http://suguk.org/blogs/the_moss-pit/archive/2008/12/22/16362.aspx</link><pubDate>Mon, 22 Dec 2008 10:32:00 GMT</pubDate><guid isPermaLink="false">19180fc3-a95d-4057-992e-fee77d73db0e:16362</guid><dc:creator>AussieNigel</dc:creator><slash:comments>3</slash:comments><comments>http://suguk.org/blogs/the_moss-pit/comments/16362.aspx</comments><wfw:commentRss>http://suguk.org/blogs/the_moss-pit/commentrss.aspx?PostID=16362</wfw:commentRss><description>&lt;div class="ExternalClass1D4FB5262CA8487387E9236E3F03977F"&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;Thought I 
would detail the steps I follow when creating a stand-alone development vm for 
SharePoint, and some of the software I like to have on one.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;I tend to use &lt;a href="http://www.vmware.com/products/ws/"&gt;&lt;strong&gt;VMWare 
Workstation&lt;/strong&gt;&lt;/a&gt; for my vm's as I like the interface, but Microsoft's &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=04d26402-3199-48a3-afa2-2dc0b40a73b6&amp;displaylang=en"&gt;&lt;strong&gt;Virtual 
PC&lt;/strong&gt;&lt;/a&gt; works just as well, with the (huge) added advantage of being 
free.  &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;I've not tried &lt;a href="http://www.microsoft.com/windowsserver2008/en/us/default.aspx"&gt;&lt;strong&gt;MS 
Windows Server 2008&lt;/strong&gt;&lt;/a&gt; as yet as it is not used at any of the business 
locations I have worked at, so this guide covers using &lt;a href="http://www.microsoft.com/windowsserver2003/default.mspx"&gt;&lt;strong&gt;Server 
2003&lt;/strong&gt;&lt;/a&gt; - though I expect the process would be almost the same on 
2008.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;&lt;br&gt;&lt;strong&gt;&lt;font color="#000080"&gt;- Build the VM&lt;/font&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;&lt;strong&gt;&lt;/strong&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;First step is to build a VM in whichever VM hosting software you are 
using.  Assign it as much RAM as you can afford on your system (I recommend at 
least 1gig), and enough disk space to cover your future needs - it is not 
possible to extend your virtual machine drive size on most VM Hosting software 
(although you can add additional virtual drives to you VM and gain more space 
that way). I tend to go for around 40Gig which, after all the software I require 
is installed, gives me around 15gig space remaining.  I also generally call my 
vm something like "DevBox32" or "DevBox64" depending on what version of the OS I 
am using.&lt;br&gt;&lt;br&gt;&lt;font color="#ff0000"&gt;&lt;b&gt;&lt;br&gt;Update:&lt;/b&gt;&lt;font color="#000000"&gt; As shown in the comments below, it is possible to increase the size of a virtual drive, but you must detatch it from the vm first - painful&lt;/font&gt;&lt;/font&gt;, but nice to know.  Many thanks to Cimares (Paul Hunt) for this little nugget.&lt;br&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;&lt;br&gt;Install your OS on the virtual machine, using the latest Release if 
possible (MS Windows Server 2003 R2 at time of writing).  &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;For development vm's, I strongly recommend the KISS practices for usernames 
and passwords, and so I use "Administrator" and "password" for the OS admin 
account. For any other OS admin-type passwords (eg the recovery password in DNS) 
I also use "password". &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;Once the install is complete, I run Windows Activate and Windows Update to 
get all the latest patches and hotfixes.  At this point, it is a really good 
idea to backup your virtual machine (ie. copy the folder on the host's 
filesystem that contains all your virtual machine's files) so that you have a 
nice "baseline" virtual machine that you can use in the future if you need to 
create other Server 2003 vm's that don't need all the rest of the stuff we are 
going to put on this one.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;&lt;br&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;&lt;strong&gt;&lt;font color="#000080"&gt;- Turn off System Beep&lt;/font&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;&lt;strong&gt;&lt;/strong&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;A lot of the installers used cause a system beep, which can be annoying for 
people sat around you, so I tend to turn it off.  Do this through using the &lt;a href="http://support.microsoft.com/kb/256986"&gt;&lt;strong&gt;Regedit&lt;/strong&gt;&lt;/a&gt; 
utility, changing the HKEY_CURRENT_USER/Control Panel/Sound/Beep to "No".  
Reboot the vm so the new setting is applied.&lt;br&gt;&lt;br&gt;--- Update: actually, have found the most effective way of switching off the system beep is to run this command fron the windows run box:&lt;br&gt;&lt;/font&gt;&lt;blockquote&gt;&lt;font face="Verdana"&gt;&lt;span class="userInput"&gt;sc config beep start= disabled&lt;/span&gt;&lt;/font&gt;&lt;br&gt;&lt;/blockquote&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;&lt;br&gt;&lt;strong&gt;&lt;font color="#000080"&gt;- AD and DNS&lt;/font&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;&lt;strong&gt;&lt;/strong&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;Now, I make the vm a Domain Controller in a new AD Forest using the "Manage 
Your Server" mmc snap-in (can be found in "Administrative Tools", and is shown 
in Server 2003 every time you log in until "Dont display this page at logon" is 
checked).  &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;I tend to call the domain "Development" and ignore the MS warning about 
using a multipart domain name. I allow the Domain Controller wizard to install 
DNS for me by selecting the appropriate option when it comes up, and reboot the 
machine at the end as the wizard directs.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;&lt;br&gt;&lt;strong&gt;&lt;font color="#000080"&gt;- Create Accounts&lt;/font&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;I then relax the Domain Security password policies, by using the "Domain 
Security Settings" snap-in in Administrative Tools.  Keep all the settings 
defined, but set them to be 0 - eg. Enforce Password History to be 0, Max 
Password Age to be 0, etc. &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;This allows me to use the username as the password also for the service and 
testuser accounts required, keeping it all nice and simple.  I then restart the 
vm so that it boots with the new password policies active.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;Once the machine is back up, I make the following accounts by going into 
"Active Directory User and Computers" snap-in, using the username as the 
password for each one, and unchecking the "User must change password at next 
logon" and checking the "Password never expires" options:&lt;/font&gt;&lt;/div&gt;
&lt;ul&gt;&lt;li&gt;&lt;font size="2" face="Tahoma"&gt;&lt;strong&gt;svc-sqlsver&lt;/strong&gt; (SQL server service account)&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Tahoma"&gt;&lt;strong&gt;svc-spsadmin&lt;/strong&gt; (SharePoint Server service account)&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Tahoma"&gt;&lt;strong&gt;svc-spsapool&lt;/strong&gt; (SharePoint Server application pool 
account)&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Tahoma"&gt;&lt;strong&gt;svc-spssearch&lt;/strong&gt; (Sharepoint Server Search account)&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Tahoma"&gt;&lt;strong&gt;testuser &lt;/strong&gt;(test user account)&lt;/font&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;font size="2" face="Tahoma"&gt;&lt;br&gt;I make each of these accounts members of the "Administration" group 
except for the testuser account.  Make it a member of the "Remote Desktop Users" 
group.&lt;/font&gt;&lt;/p&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;&lt;br&gt;&lt;strong&gt;&lt;font color="#000080"&gt;- Application Server&lt;/font&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;Next step is to install the dotNet frameworks - I install versions &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=0856EACB-4362-4B0D-8EDD-AAB15C5E04F5"&gt;&lt;strong&gt;2.0&lt;/strong&gt;&lt;/a&gt; 
and &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=10CC340B-F857-4A14-83F5-25634C3BF043"&gt;&lt;strong&gt;3.0&lt;/strong&gt;&lt;/a&gt;. 
After they are installed, run Windows update to get the latest service packs and 
fixes for these on. &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;When this is complete, open the "Manage Your Server" snap-in again, and add 
the "Application Server" role.  When installing this, ensure "Frontpage 
extensions" remains unchecked, and check "Enable asp.net".&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;At this point we have finished with the "Manage my Server" snap-in, so I 
check "Don't display this page at logon" and close it.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;&lt;br&gt;&lt;strong&gt;&lt;font color="#000080"&gt;- Turn off IE Enhanced 
Security&lt;/font&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;Again, to keep the whole environment simple, I turn off IE's enhanced 
security.  Do this by opening "Add or Remove Programs" in the Administrative 
Tools, and selecting "Add/Remove Windows Components". "Internet Explorer Enhance 
Security Configuration is an option in this list.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;&lt;br&gt;&lt;strong&gt;&lt;font color="#000080"&gt;- Install SQL Server&lt;/font&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;Next step is to get the database on there.  I tend to use &lt;a href="http://technet.microsoft.com/en-us/sqlserver/default.aspx"&gt;&lt;strong&gt;SQL 
Server 2005&lt;/strong&gt;&lt;/a&gt;, and first install the server component, ensuring "SQL 
Server Databse Services", "Analysis Services", "Report Services" and 
"Integration Services" are installed. &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;Use the "svc-sqlsvr" account we created earlier for the service account, 
and use Windows Auth mode. Collation can be a prickly issue with some DBAs, but 
I just use the default on my vm.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;I then install the SQL server client components on the vm, ensuring that 
the "Connectivity components", "Management Tools" and "Legacy Components" are 
installed.  &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;On completion of the client tools installing, I reboot the virtual machine 
(to remove some file locks these installs leave about).&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;When the vm has rebooted, I install SP3 for SQL Server, and then run 
windows update (it is cumulative, so includes SP1 and SP2).&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;&lt;br&gt;&lt;strong&gt;&lt;font color="#000080"&gt;- SharePoint&lt;/font&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;I generally install &lt;a href="http://www.microsoft.com/sharepoint/default.mspx"&gt;&lt;strong&gt;MOSS 
Enterprise&lt;/strong&gt;&lt;/a&gt; on my vm's, as this is what most of the companies I have 
worked for are using. &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;Install it as a full install (not single machine) so that MSDE is not 
installed, and use the svc-spsadmin account when prompted. &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;Once it has completed installing, I then put on the &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=4191A531-A2E9-45E4-B71E-5B0B17108BD2"&gt;&lt;strong&gt;WSS 
SP1&lt;/strong&gt;&lt;/a&gt;, &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=AD59175C-AD6A-4027-8C2F-DB25322F791B"&gt;&lt;strong&gt;MOSS 
SP1&lt;/strong&gt;&lt;/a&gt; and then any &lt;a href="http://blogs.msdn.com/sharepoint/archive/2008/07/15/announcing-availability-of-infrastructure-updates.aspx"&gt;&lt;strong&gt;infrastructure 
updates&lt;/strong&gt;&lt;/a&gt; (in that order). MSDN license holders will note that there 
is a version of MOSS available that has SP1 integrated with it.  I have found 
that this contains DLLs of a different version to a base MOSS install that has 
had SP1 applied against it, meaning backup/restores of site collections from one 
to the other fails to work because of version incompatabilities.  Because of 
this, I tend to just build it from the base up.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;&lt;br&gt;&lt;strong&gt;&lt;font color="#000080"&gt;- Office and SharePoint 
Designer&lt;/font&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;&lt;a href="http://office.microsoft.com/"&gt;&lt;strong&gt;Office 2007&lt;/strong&gt;&lt;/a&gt; are 
the next things to go onto the vm. You need Office 2007 on there to replicate 
your general users environment and perform any sort of testing. Although I am 
not a big fan of &lt;a href="http://office.microsoft.com/en-us/sharepointdesigner/FX100487631033.aspx"&gt;&lt;strong&gt;SharePoint 
Designer&lt;/strong&gt;&lt;/a&gt;, it can be a handy piece of kit to have around.  &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;I install both these pieces, then run windows update to get the latest 
patches, and then activate them.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;&lt;br&gt;&lt;strong&gt;&lt;font color="#000080"&gt;- Visual Studio and Source 
Safe&lt;/font&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;Time to put the development IDE on - I use &lt;a href="http://msdn.microsoft.com/en-us/vstudio/default.aspx"&gt;&lt;strong&gt;Visual 
Studio 2008&lt;/strong&gt;&lt;/a&gt;.  I also stick on &lt;a href="http://msdn.microsoft.com/en-us/vstudio/aa700907.aspx"&gt;&lt;strong&gt;Visual 
Source Safe&lt;/strong&gt;&lt;/a&gt; so that I have some form of source control (even one 
that can't do proper branching/merging ;)&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;&lt;br&gt;&lt;strong&gt;&lt;font color="#000080"&gt;- SDK's and more&lt;/font&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;Spend any time developing with SharePoint object model and you will realize 
having the SDK's available is invaluable.  I stick on both the &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=05E0DD12-8394-402B-8936-A07FE8AFAFFD&amp;displaylang=en"&gt;&lt;strong&gt;WSS 
SDK&lt;/strong&gt;&lt;/a&gt; and the &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=6D94E307-67D9-41AC-B2D6-0074D6286FA9&amp;displaylang=en"&gt;&lt;strong&gt;Office 
Server (MOSS) SDK&lt;/strong&gt;&lt;/a&gt;.  I also put on the &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=7bf65b28-06e2-4e87-9bad-086e32185e68"&gt;&lt;strong&gt;WSS 
Visual Studio Extensions&lt;/strong&gt;&lt;/a&gt; so I can get the SharePoint Solution 
Generator.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;&lt;br&gt;&lt;strong&gt;&lt;font color="#000080"&gt;- Desktop Shortcuts&lt;/font&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;Make some desktop shortcuts now for the Hive-12, your wwwroot/vss 
directory, wherever you are storing your studio project files, and a command 
prompt for accessing STSADM.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;&lt;br&gt;&lt;strong&gt;&lt;font color="#000080"&gt;- Niceties&lt;/font&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;&lt;strong&gt;&lt;/strong&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;At this point, you have a nice development vm ready for use, but there are 
some other "niceties" that you should consider installing to make your life 
easier:&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;ul&gt;&lt;li&gt;&lt;font size="2" face="Tahoma"&gt;&lt;a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx"&gt;&lt;strong&gt;Powershell&lt;/strong&gt;&lt;/a&gt; 
and the &lt;a href="http://www.powergui.org/"&gt;&lt;strong&gt;PowerGUI&lt;/strong&gt;&lt;/a&gt; - to 
enable some power scripting&lt;br&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Tahoma"&gt;&lt;a href="http://www.red-gate.com/products/reflector/"&gt;&lt;strong&gt;Reflector&lt;/strong&gt;&lt;/a&gt; 
- brilliant bit of reverse engineering kit - install it into your 'ProgramFiles' 
directory, and make a shortcut in your Start menu&lt;br&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Tahoma"&gt;&lt;a href="http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx"&gt;&lt;strong&gt;DebugView&lt;/strong&gt;&lt;/a&gt; 
- the best way for outputting debug statements - install it into your 
'ProgramFiles' directory, and make a shortcut in your Start menu&lt;br&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Tahoma"&gt;&lt;strong&gt;&lt;a href="http://www.fiddlertool.com/"&gt;Fiddler&lt;/a&gt;&lt;/strong&gt; - useful 
proxy-ing debug tool&lt;br&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Tahoma"&gt;&lt;a href="http://www.adobe.com/"&gt;&lt;strong&gt;Adobe Acrobat&lt;/strong&gt;&lt;/a&gt; - you are 
going to need it on there sooner or later&lt;br&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Tahoma"&gt;&lt;strong&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=e59c3964-672d-4511-bb3e-2d5e1db91038"&gt;MS 
IE Dev toolbar&lt;/a&gt;&lt;/strong&gt; - In-browser set of dev tools&lt;br&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Tahoma"&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=E82EA71D-DA89-42EE-A715-696E3A4873B2"&gt;&lt;strong&gt;MS 
Sandcastle&lt;/strong&gt;&lt;/a&gt;, &lt;a href="http://msdn.microsoft.com/en-us/library/ms669985.aspx"&gt;&lt;strong&gt;HTML 
Help&lt;/strong&gt;&lt;/a&gt; and &lt;a href="http://www.codeplex.com/SHFB"&gt;&lt;strong&gt;Sandcastle 
Helpfile Builder&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt; &lt;/strong&gt;- the replacement for ndoc that I 
use for producing API doc&lt;br&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Tahoma"&gt;&lt;a href="http://www.adselfservicesuite.com/SharePointExplorerClient.aspx"&gt;&lt;strong&gt;SharePoint 
Explorer Community Edition&lt;/strong&gt;&lt;/a&gt; - brilliant free in-browser toolbar for 
administering a sharepoint site - will save you hours!&lt;br&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Tahoma"&gt;&lt;a href="http://www.textpad.com/"&gt;&lt;strong&gt;Textpad&lt;/strong&gt;&lt;/a&gt; - everyone 
has a favourite notepad replacement, mine is textpad&lt;br&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Tahoma"&gt;&lt;strong&gt;&lt;a href="http://www.7-zip.org/"&gt;7-Zip&lt;/a&gt;&lt;/strong&gt; - great free 
compression utility - supports most formats&lt;br&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Tahoma"&gt;&lt;strong&gt;&lt;a href="http://technet.microsoft.com/en-us/sysinternals/bb897557.aspx"&gt;BGInfo&lt;/a&gt;&lt;/strong&gt; 
- updates your desktop background with system information - useful for easily 
seeing whats what on your vm&lt;br&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Tahoma"&gt;&lt;strong&gt;&lt;a href="http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx"&gt;Process 
Explorer&lt;/a&gt;&lt;/strong&gt; - powerful (though resource hungry) replacement for the 
windows Task Manager&lt;br&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Tahoma"&gt;&lt;strong&gt;&lt;a href="http://office.microsoft.com/infopath"&gt;Infopath Forms 
Server&lt;/a&gt;&lt;/strong&gt; - if it is used in your prod setup&lt;/font&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;&lt;br&gt;Lastly, but certainly not leastly, create a README.TXT to be stored 
with your vm files that explains what OS and SP is on it, what else is installed 
etc. - much easier to open a text file then have to boot the vm and poke 
around.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;&lt;br&gt;Happy dev-ing!!&lt;br&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;&lt;/div&gt;&lt;img src="http://suguk.org/aggbug.aspx?PostID=16362" width="1" height="1"&gt;</description></item><item><title>Logging in Context</title><link>http://suguk.org/blogs/the_moss-pit/archive/2008/11/10/15066.aspx</link><pubDate>Mon, 10 Nov 2008 15:36:00 GMT</pubDate><guid isPermaLink="false">19180fc3-a95d-4057-992e-fee77d73db0e:15066</guid><dc:creator>AussieNigel</dc:creator><slash:comments>0</slash:comments><comments>http://suguk.org/blogs/the_moss-pit/comments/15066.aspx</comments><wfw:commentRss>http://suguk.org/blogs/the_moss-pit/commentrss.aspx?PostID=15066</wfw:commentRss><description>&lt;DIV&gt;I think everyone agrees that proper error trapping and logging is a good idea - how else are you supposed to be able to work out what has gone wrong on a production system where you can't simply connect Visual Studio up and start debugging?&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt; &lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face=Verdana size=2&gt;But too many times I have seen logging calls where the developer simply captures an exception and logs its .Message - this is lazy, and in an environment which has multiple web-front ends and hundreds (maybe thousands) of users, next to useless for the poor support staff who's job it is to check the logs the next day.  What is a log message that only contains "Object not set to an instance of an object" going to tell them then??&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt; &lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV&gt;&lt;FONT face=Verdana size=2&gt;&lt;STRONG&gt;Every log message should have some contextual information which qualifies the log message!!&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt; &lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face=Verdana size=2&gt;It is taken for granted that the Date/Time of the error should be included in the log (kind of automatic if you are logging to an Event Log), but a whole lot more information should also be included - some examples might be: &lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face=Verdana size=2&gt;- the user who was in context when the error occured; &lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face=Verdana size=2&gt;- the SPWeb that the web part in error was active on;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face=Verdana size=2&gt;- the name of the SPList that was trying to be accessed; etc. etc.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt; &lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face=Verdana size=2&gt;Providing this kind of contextual information may mean that instead of one huge try...catch loop, you need to use a few - so be it.  The value gained by having meaningful logging messages is more then worth it.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt; &lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face=Verdana size=2&gt;The aim for every log message should be to provide enough information so that someone who comes along later and reads it can easily determine what has gone wrong where, and guide them to the solution to rectify the problem.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt; &lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt; &lt;/DIV&gt;&lt;img src="http://suguk.org/aggbug.aspx?PostID=15066" width="1" height="1"&gt;</description></item><item><title>Adding a Tree Control column to SharePoint</title><link>http://suguk.org/blogs/the_moss-pit/archive/2008/11/10/15062.aspx</link><pubDate>Mon, 10 Nov 2008 14:50:00 GMT</pubDate><guid isPermaLink="false">19180fc3-a95d-4057-992e-fee77d73db0e:15062</guid><dc:creator>AussieNigel</dc:creator><slash:comments>6</slash:comments><comments>http://suguk.org/blogs/the_moss-pit/comments/15062.aspx</comments><wfw:commentRss>http://suguk.org/blogs/the_moss-pit/commentrss.aspx?PostID=15062</wfw:commentRss><description>&lt;div&gt;&lt;font size="2" face="Verdana"&gt; One of the things that SharePoint is lacking out-of-the-box is a tree control field type.  In a recent project, we required one, so that list items and document library items could be tagged appropriately using hierarchical in-house taxonomies.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;Additional requirements for this tree control included that multiple nodes in the tree were able to be selected, and that the data displayed in the tree could be maintained by non-IT Admin staff.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;Luckily, SharePoint allows you to define and create your own custom field types.  We decided that a tree control that stored the tree node path for selected nodes as a string would suffice.  So, for example, the following:&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;br&gt;&lt;font size="2" face="Verdana"&gt;&lt;img alt="" src="http://www.thesug.org/blogs/moss-pit/MossPit%20Images/TreeControl.JPG"&gt;&lt;br&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;would be stored as: "&lt;strong&gt;Americas/North America/USA; Europe/United Kingdom&lt;/strong&gt;"&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Verdana"&gt;To meet the requirement that it could be maintained by non-IT staff, it was decided to source the tree from a SharePoint list.  The list structure was defined to have the following columns:&lt;/font&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;font size="2" face="Verdana"&gt;Title - unused, but always sensible to leave this field in your custom lists, as some SharePoint functionality expects it to be there. &lt;/font&gt;
&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Verdana"&gt;Level1 &lt;/font&gt;
&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Verdana"&gt;Level2 &lt;/font&gt;
&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Verdana"&gt;Levelx - The level columns hold the node names for that level of the tree control.  The root node of the tree is the name of the list &lt;/font&gt;
&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Verdana"&gt;HoverText - Tooltip text to be displayed when user hovers over that node &lt;/font&gt;
&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Verdana"&gt;ShowCheckbox - if that node should display a checkbox or not&lt;br&gt;&lt;/font&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;a href="http://www.thesug.org/blogs/moss-pit/MossPit%20Images/TreeListData.JPG"&gt;&lt;font size="2" face="Verdana"&gt;&lt;img alt="" src="http://www.thesug.org/blogs/moss-pit/MossPit%20Images/TreeListData.JPG" width="676" height="120"&gt;&lt;/font&gt;&lt;/a&gt;&lt;font face="Verdana"&gt;&lt;font size="2"&gt; &lt;br&gt;&lt;em&gt;(click to see a version that isnt squashed down)&lt;/em&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt;&lt;/strong&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;font size="2" face="Verdana"&gt;How to create the Custom Field&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Verdana"&gt;When creating a custom field, there are 3 aspects that must be addressed:&lt;br&gt;&lt;br&gt;1) The Field Type Definition&lt;br&gt;2) The UI and logic for adding your field to a list&lt;br&gt;3) The UI and logic for your field when an item in that list is being edited&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Verdana"&gt;(Note: you could have a fourth section here if you wanted to customise the way your field was displayed when the list item properties were viewed, but I was happy for the tree node path to be displayed as text, so no customization was required).&lt;br&gt;&lt;br&gt;The WSP package associated with this post installs the following files:&lt;br&gt;- …\TEMPLATE\CONTROLTEMPLATES\TreeListControl.ascx&lt;br&gt;- …\TEMPLATE\CONTROLTEMPLATES\TreeListEditControl.ascx&lt;br&gt;- …\TEMPLATE\XML\FLDTYPE_TreeList.XML&lt;br&gt;- TreeListControl.dll (to the GAC)&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;u&gt;&lt;/u&gt;&lt;/strong&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;u&gt;&lt;br&gt;&lt;font color="#008080" face="Verdana"&gt;1 - The Field Type definition&lt;/font&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Verdana"&gt;There are two parts to defining your field - the code implements your field type, and the FLDTYPES_name.XML file that contains all the information SharePoint requires to implement your custom field.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;font size="2" face="Verdana"&gt;1) The code that implements the field type&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Verdana"&gt;The class for your custom field is going to override one of the existing SPField types.  My class here, “TreeListControl.TreeListField” (contained in FieldDef.cs),  inherits from SPFieldsMultiLineText.  The major change to this class that mine is making is the addition of a “Dictionary” collection to hold the property values for the field:&lt;br&gt;&lt;/font&gt;&lt;/p&gt;&lt;code&gt;
&lt;/code&gt;&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;&lt;font size="2" color="#008000"&gt;
&lt;/font&gt;&lt;p&gt;&lt;font size="2" color="#008000"&gt;//Dictionary of property values&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;private&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;static&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font size="2" color="#008080"&gt;Dictionary&lt;/font&gt;&lt;font size="2"&gt;&lt;font size="2" color="#0000ff"&gt;int&lt;/font&gt;&lt;font size="2"&gt;, &lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;string&lt;/font&gt;&lt;font size="2"&gt;&gt; dictUpdatedPropertyValue = &lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;new&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font size="2" color="#008080"&gt;Dictionary&lt;/font&gt;&lt;font size="2"&gt;&lt;font size="2" color="#0000ff"&gt;int&lt;/font&gt;&lt;font size="2"&gt;, &lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;string&lt;/font&gt;&lt;font size="2"&gt;&gt;();&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;font size="2" color="#008000"&gt;//Properties in a delimited string&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;private&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;string&lt;/font&gt;&lt;font size="2"&gt; _delimitedPropertyValues;&lt;/font&gt;&lt;/p&gt;&lt;font size="2"&gt;&lt;/font&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;When users choose to add this field (say as a custom column in a list) they are asked to set some properties about (the source list for the tree, number of levels, etc.).  These values need to be stored by your custom field so they can be used later on when implementing the field.  The dictionary collection is used to store these property values.  Until the values are put in the dictionary, they are held in a the _delimitedProperty values string.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;I also added the following properties to allow me to access the dictionary: &lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;&lt;span&gt;&lt;font size="2" color="#808080"&gt;
&lt;/font&gt;&lt;p&gt;&lt;font size="2" color="#808080"&gt;///&lt;/font&gt;&lt;font size="2" color="#008000"&gt; &lt;/font&gt;&lt;font size="2" color="#808080"&gt;&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#808080"&gt;///&lt;/font&gt;&lt;font size="2" color="#008000"&gt; Access the delimited properties for the control&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#808080"&gt;///&lt;/font&gt;&lt;font size="2" color="#008000"&gt; &lt;/font&gt;&lt;font size="2" color="#808080"&gt;&lt;/font&gt;&lt;/p&gt;&lt;font size="2" color="#808080"&gt;&lt;/font&gt;&lt;font size="2"&gt;
&lt;/font&gt;&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;public&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;string&lt;/font&gt;&lt;font size="2"&gt; DelimitedPropertyValues&lt;br&gt;{&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;    get&lt;/font&gt;&lt;font size="2"&gt; { &lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;return&lt;/font&gt;&lt;font size="2"&gt; dictUpdatedPropertyValue.ContainsKey(ContextId) ? dictUpdatedPropertyValue[ContextId] : _delimitedPropertyValues; }&lt;br&gt;    &lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;set&lt;/font&gt;&lt;font size="2"&gt; { &lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;this&lt;/font&gt;&lt;font size="2"&gt;._delimitedPropertyValues = &lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;value&lt;/font&gt;&lt;font size="2"&gt;; }&lt;br&gt;}&lt;/font&gt;&lt;/p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/span&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;And very importantly, I override the base field rendering control, so that my TreeList control will be rendered:&lt;br&gt;&lt;br&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;
&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;font size="2" face="Verdana"&gt;&lt;font size="2" color="#808080"&gt;
&lt;/font&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" color="#808080"&gt;///&lt;/font&gt;&lt;font size="2" color="#008000"&gt; &lt;/font&gt;&lt;font size="2" color="#808080"&gt;&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#808080"&gt;///&lt;/font&gt;&lt;font size="2" color="#008000"&gt; Override the field rendering control to use the custom TreeList control&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#808080"&gt;///&lt;/font&gt;&lt;font size="2" color="#008000"&gt; &lt;/font&gt;&lt;font size="2" color="#808080"&gt;&lt;/font&gt;&lt;/p&gt;&lt;font size="2" color="#808080"&gt;&lt;/font&gt;&lt;font size="2"&gt;
&lt;/font&gt;&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;public&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;override&lt;/font&gt;&lt;font size="2"&gt; Microsoft.SharePoint.WebControls.BaseFieldControl FieldRenderingControl&lt;br&gt;{&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;   get&lt;br&gt;   &lt;/font&gt;&lt;font size="2"&gt;{&lt;br&gt;      Microsoft.SharePoint.WebControls.BaseFieldControl TreeList = &lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;new&lt;/font&gt;&lt;font size="2"&gt; TreeList();&lt;br&gt;      TreeList.FieldName = InternalName;&lt;br&gt;      &lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;return&lt;/font&gt;&lt;font size="2"&gt; TreeList;&lt;br&gt;   &lt;/font&gt;&lt;font size="2"&gt;}&lt;br&gt;}&lt;/font&gt;&lt;/p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/font&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;The rest of the functions in this class are quite straight forward, and simply used for maintaining the values stored in the dictionary.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;br&gt;&lt;strong&gt;&lt;font size="2" face="Verdana"&gt;2) The FLD_type.XML&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;strong&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt;&lt;/strong&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt; This file defines the field for SharePoint, and gets deployed to …\12\TEMPLATE\XML. most of the fields in here are pretty self-explanatory, though I would like to highlight a few of them:&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;br&gt;&lt;/font&gt; &lt;/p&gt;&lt;font size="2" color="#0000ff"&gt;
&lt;/font&gt;&lt;p&gt;&lt;font size="2" color="#0000ff"&gt;&lt;font face="Courier New"&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size="2" color="#800000"&gt;Field&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt; &lt;/font&gt;&lt;font size="2" color="#ff0000"&gt;Name&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;=&lt;/font&gt;&lt;font size="2"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;ParentType&lt;/font&gt;&lt;font size="2"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;&gt;&lt;/font&gt;&lt;font size="2"&gt;Note&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;&lt;font size="2" color="#800000"&gt;Field&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Verdana"&gt;Setting the parent type of the field to “Note” allows this field allows us to avoid the 255character limit that most of the other parent fields type’s have - a Note field has no character length restriction.&lt;br&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;
&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;font size="2" face="Verdana"&gt;&lt;font size="2" color="#0000ff"&gt;
&lt;/font&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" color="#0000ff"&gt;&lt;font face="Courier New"&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size="2" color="#800000"&gt;Field&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt; &lt;/font&gt;&lt;font size="2" color="#ff0000"&gt;Name&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;=&lt;/font&gt;&lt;font size="2"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;FieldTypeClass&lt;/font&gt;&lt;font size="2"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;&gt;&lt;/font&gt;&lt;font size="2"&gt;TreeListControl.TreeListField, TreeListControl, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9f525b76b9e4fb66&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;&lt;font size="2" color="#800000"&gt;Field&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;font face="Courier New"&gt;&lt;font size="2" color="#0000ff"&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;This defines the assembly and class therein that implements this field.&lt;br&gt;&lt;br&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt; &lt;/font&gt;&lt;/p&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt;
&lt;p class="MsoNormal"&gt;
&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;font size="2" face="Verdana"&gt;&lt;font size="2" color="#0000ff"&gt;&lt;font face="Courier New"&gt;&lt;/font&gt;&lt;font size="2" color="#008000" face="Courier New"&gt; Property Schema with single field to hold the custom properties for this field &lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size="2" color="#0000ff"&gt;--&gt;&lt;br&gt;&lt;font size="2" color="#800000"&gt;PropertySchema&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size="2" color="#0000ff"&gt;&gt;&lt;br&gt;   &lt;font size="2" color="#800000"&gt;Fields&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size="2" color="#0000ff"&gt;&gt;&lt;br&gt;      &lt;font size="2" color="#800000"&gt;Field&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt; &lt;/font&gt;&lt;font size="2" color="#ff0000"&gt;ID&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;=&lt;/font&gt;&lt;font size="2"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;DelimitedPropertyValues&lt;/font&gt;&lt;font size="2"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt; &lt;/font&gt;&lt;font size="2" color="#ff0000"&gt;Hidden&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;=&lt;/font&gt;&lt;font size="2"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;TRUE&lt;/font&gt;&lt;font size="2"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt; &lt;/font&gt;&lt;font size="2" color="#ff0000"&gt;Name&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;=&lt;/font&gt;&lt;font size="2"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;DelimitedPropertyValues&lt;/font&gt;&lt;font size="2"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt; &lt;/font&gt;&lt;font size="2" color="#ff0000"&gt;DisplayName&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;=&lt;/font&gt;&lt;font size="2"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;(Hidden) DelimitedPropertyValues&lt;/font&gt;&lt;font size="2"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt; &lt;/font&gt;&lt;font size="2" color="#ff0000"&gt;Type&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;=&lt;/font&gt;&lt;font size="2"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;Text&lt;/font&gt;&lt;font size="2"&gt;"&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size="2" color="#0000ff"&gt; /&gt; &lt;br&gt;   &lt;font size="2" color="#800000"&gt;Fields&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size="2" color="#0000ff"&gt;&gt;&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;&lt;font size="2" color="#800000"&gt;PropertySchema&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;&gt;&lt;br&gt;
&lt;p&gt;&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;div class="MsoNormal"&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;As the comment indicates, the property schema section is where we define our field type has an additional hidden field used for holding our properties.  This “PropertySchema” was meant to allow you to define multiple property fields (one per property), but there is a bug that prevents this from working.  Hence, we store one property, which in actuality is a delimited string of all our properties.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;strong&gt;&lt;u&gt;&lt;font color="#008080" face="Verdana"&gt;2 - UI and Logic for adding your Field to a List&lt;/font&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;strong&gt;&lt;u&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt;&lt;/u&gt;&lt;/strong&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;This basically refers to presenting a screen to allow a user to set or change the properties that your custom field uses, and storing these property settings.  So it deals with our “DelimitedPropertyValues” property above.&lt;br&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" dir="ltr"&gt;&lt;font size="2" face="Verdana"&gt;My Tree control is going to have 10 properties:&lt;br&gt;&lt;br&gt;1. Site (string) - the name of the site holding the list of data that defines this tree.&lt;br&gt;&lt;br&gt;2. ListName (string) - the name of this list holding the tree data.&lt;br&gt;&lt;br&gt;3. Levels (int) - the number of levels this tree has.  user will select list via a dropdown.&lt;br&gt;&lt;br&gt;4. SortByAlpha (bool) - whether the nodes in this list will be sorted alphabetically, or be displayed the way they occur in the list.&lt;br&gt;&lt;br&gt;5. ShowSetNull (bool) - if a “Set this value to be null” link should be displayed beneath the tree.&lt;br&gt;&lt;br&gt;6. ShowCheckboxes (bool) - if this tree should render checkboxes on nodes as defined in the list holding the tree data.&lt;br&gt;&lt;br&gt;7. CheckBoxDisplay (string) - a string indicating if the checkboxes should be displayed on “All Nodes”, “Leaf nodes” or “List Defined” nodes.  User will select which one via a dropdown.&lt;br&gt;&lt;br&gt;8. AutoCheckSubnodes (bool) - if a node containing subnodes is checked, should they all be automatically checked also.&lt;br&gt;&lt;br&gt;9. ExpandCheckedNodes (bool) - if the tree should load in an expanded state, showing all nodes that have been checked.&lt;br&gt;&lt;br&gt;10. ShowHoverText (bool) - indicates if the tree control should show the hover text as defined in the list holding the Tree data.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;br&gt;&lt;font size="2" face="Verdana"&gt; &lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;So, the first thing I need to do is to create a control that allows the user to set all of these properties when they use my custom field.  &lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;In my fileset, the control is the TreeListEditField.ASCX file, and it gets deployed to …\12\TEMPLATE\CONTROLTEMPLATES.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;The majority of this control is fairly straight forward, simple ASP.Net controls like Labels and TextBoxes to gather my property values, but you may not be familiar with the controls that enclose these, ie:&lt;br&gt;&lt;br&gt;&lt;/font&gt;&lt;/p&gt;&lt;/div&gt;
&lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span&gt;wssuc&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt;InputFormSection&lt;/span&gt;&lt;span&gt; &lt;span&gt;runat&lt;/span&gt;&lt;span&gt;="server"&lt;/span&gt; &lt;span&gt;id&lt;/span&gt;&lt;span&gt;="MySections"&lt;/span&gt; &lt;span&gt;Title&lt;/span&gt;&lt;span&gt;="Tree List Details"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span&gt;       &lt;/span&gt;&lt;span&gt;&lt;span&gt;Template_InputFormControls&lt;/span&gt;&lt;span&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span&gt;      &lt;/span&gt;&lt;span&gt;       &lt;/span&gt;&lt;span&gt;&lt;span&gt;wssuc&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt;InputFormControl&lt;/span&gt; &lt;span&gt;runat&lt;/span&gt;&lt;span&gt;="server"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span&gt;                    &lt;/span&gt;&lt;span&gt;&lt;span&gt;Template_Control&lt;/span&gt;&lt;span&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt;
&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;The “InputFormSection” control &amp; “InputFormControl” are SharePoint controls that creates the standard look and feel that SharePoint forms have.  So, with those encasing my control (made up of labels, textboxes, dropdowns etc), I end up with something like this:&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;a href="http://www.thesug.org/blogs/moss-pit/MossPit%20Images/TreeListEdit.JPG"&gt;&lt;font size="2" face="Verdana"&gt;&lt;img alt="" src="http://www.thesug.org/blogs/moss-pit/MossPit%20Images/TreeListEdit.JPG" width="385" height="288"&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;em&gt;&lt;font size="2" face="Verdana"&gt;(click to see an image that is not squashed down)&lt;/font&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;Great, so now I need to put together the code that is going to be associated with this control.  All this code really needs to do is to create the correct DelimitedPropertyString for the values set by the user in the control.  So (for example) if they have checked a checkbox, put a “True;” in the delimited string.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;I have a little logic around the “Load Lists” functionality - I want the user to enter a url to a SharePoint site containing the list holding the tree data, to then click a button to load the lists on this site into a dropdown, and finally to select which specific list holds the tree data.  I ensure that the path to the site is a relative url by removing the root url for the current web application if it exists in the given site url.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;The OnSaveChange method is used to create a delimited string for all the properties, and then set this string against the controls “DelimitedPropertyValues” property.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;So that we set these controls to have the correct values when someone is editing an existing TreeList column, the InitializeWithField method must parse the “DelimitedPropertyValues” string and set the state of the controls to be correct as per the values contained in that string.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;strong&gt;&lt;u&gt;&lt;font color="#008080" face="Verdana"&gt;3 - UI and Logic for your Field when an item in that list is being edited&lt;/font&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;br&gt;&lt;font size="2" face="Verdana"&gt;This is very similar to the previous section, except we are now defining how the column will look and behave when that list item is being edited - that is, that it will display the tree as defined by our list.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;As with the TreeListEditField control, this is an ascx file that gets stored on the filesystem at …\12\TEMPLATE\CONTROLTEMPLATES.  In the attached solution, this control is called TreeListFieldControl.ascx.  &lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;It is made up of three parts - the tree control, a link that can be used to set the string value set by tree control to null, and a label that can be used to show the current string value.  These controls are contained by a “RenderingTemplate” control, which allows us to create our control from these three parts.&lt;br&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span&gt;SharePoint&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt;RenderingTemplate&lt;/span&gt;&lt;span&gt; &lt;span&gt;ID&lt;/span&gt;&lt;span&gt;="TreeList"&lt;/span&gt; &lt;span&gt;runat&lt;/span&gt;&lt;span&gt;="server"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span&gt;    &lt;/span&gt;&lt;span&gt;&lt;span&gt;Template&lt;/span&gt;&lt;span&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span&gt;        &lt;/span&gt;&lt;span&gt;&lt;span&gt;asp&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt;TreeView&lt;/span&gt; &lt;span&gt;runat&lt;/span&gt;&lt;span&gt;="server"&lt;/span&gt; &lt;span&gt;ID&lt;/span&gt;&lt;span&gt;="treeList"&lt;/span&gt; &lt;span&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span&gt;        &lt;/span&gt;&lt;span&gt;&lt;span&gt;br&lt;/span&gt; &lt;span&gt;/&gt;&lt;span&gt;br&lt;/span&gt; &lt;span&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span&gt;        &lt;/span&gt;&lt;span&gt;&lt;span&gt;asp&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt;LinkButton&lt;/span&gt; &lt;span&gt;ID&lt;/span&gt;&lt;span&gt;="setNullLink"&lt;/span&gt; &lt;span&gt;runat&lt;/span&gt;&lt;span&gt;="server"&lt;/span&gt; &lt;span&gt;Text&lt;/span&gt;&lt;span&gt;="Set this value to be null"&gt;&lt;span&gt;asp&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt;LinkButton&lt;/span&gt;&lt;span&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span&gt;        &lt;/span&gt;&lt;span&gt;&lt;span&gt;br&lt;/span&gt; &lt;span&gt;/&gt;&lt;span&gt;br&lt;/span&gt; &lt;span&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span&gt;        &lt;/span&gt;&lt;span&gt;&lt;span&gt;asp&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt;Label&lt;/span&gt;&lt;span&gt;  &lt;/span&gt;&lt;span&gt;ID&lt;/span&gt;&lt;span&gt;="valueLabel"&lt;/span&gt; &lt;span&gt;runat&lt;/span&gt;&lt;span&gt;="server"&gt;&lt;span&gt;asp&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt;Label&lt;/span&gt;&lt;span&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span&gt;    &lt;/span&gt;&lt;span&gt;&lt;span&gt;Template&lt;/span&gt;&lt;span&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font face="Verdana"&gt;&lt;span&gt;&lt;span&gt;SharePoint&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt;RenderingTemplate&lt;/span&gt;&lt;span&gt;&gt;&lt;/span&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt;
&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;Ok, so like before, we now need to implement the code that is going to be associated with this control.  This code has quite a bit to do - it must get the properties that have been set against the control, then build the tree control from the designated list, and configure it based on the properties.  &lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;I am not going to describe how the code does this in depth, as it is well commented in the cs file, and hopefully is easy to understand, however I want to point out that I use a viewstate variable (“drawnTree”) to determine whether to run the tree creation code, rather then the usual “if !Page.IsPostBack”. &lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;This is because we use this control on created web pages (in the “PublishingControls:EditModePanel”), which means a page could be considered a postback (say, after web parts have been added) and the tree control not drawn.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;And that’s it.  Install the solution to your farm (you can use the ~InstallSolution.bat included to help with this), deploy it to your web application (best to do this through central admin), and then it should be available for use in your lists and site columns.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;font size="2" face="Verdana"&gt;Some things to note:&lt;br&gt;&lt;br&gt;• The code currently assumes all users will have read access to the list containing the tree control data, if this is not true, you will need to implement some impersonation in the code around where it parses this list and builds the tree&lt;br&gt;&lt;br&gt;• Because the checked tree nodes are stored as a string showing the TreeNode path, the ‘/’ character cannot be used in any of the tree node names&lt;br&gt;&lt;br&gt;• I have taken out all of my logging and tracing calls, as these rely on other in-house code libraries. If you want to use this code in a prod system, I suggest you add your own in there&lt;br&gt;&lt;br&gt;• I have taken out the custom styling classes (css) from the ascx’s, you may want to consider adding in your own&lt;br&gt;&lt;br&gt;• Although this control works as is, this is really meant as a starting point for you to implement the control you need - an XML file might be a better source for your tree data, you might not like the strict design for the tree data list this control requires, you might want additional tree functionality, etc.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Verdana"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Verdana"&gt;The Visual Studio 2008 solution is in the "TreeListControl.zip" attached to this post - contains compiled WSP file, so can be installed and used directly on SharePoint install.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt; &lt;br&gt;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-&lt;br&gt;&lt;/p&gt;&lt;font size="2" face="Verdana"&gt;&lt;br&gt;After recieving a number of comments on this tree control, I feel I should point out that, as only the text of the tree node is stored against a list item, changing the value of the tree node by updating list item value that sources the tree nodes will &lt;b&gt;not&lt;/b&gt; cause the value to be automatically updated on all the list items it is applied against.&lt;br&gt;&lt;br&gt;It would be a simple change to make the Tree control store a list item guid rather then the node path string, which would then make this possible.&lt;br&gt;&lt;br&gt;The company I wrote this for uses an external search provider (not microsoft), and it was easier for them to process a bunch of node paths to provide their search filters, rather then to process a bunch of id's, and perform a lookup back to a sharepoint list, hence this design was used.&lt;br&gt;&lt;br&gt;To resolve this problem for the company mentioned, we created a web part which allows the user to update the values assigned to list items.  So when they want to change a tree node item, they delete the item in the list, create a new one, then use this web part to change the original items node path to the new items node path - not really an ideal solution, but seems to work well enough.&lt;br&gt;&lt;/font&gt;
&lt;p&gt;&lt;font size="2" face="Verdana"&gt; &lt;/font&gt;&lt;/p&gt;&lt;img src="http://suguk.org/aggbug.aspx?PostID=15062" width="1" height="1"&gt;</description><enclosure url="http://suguk.org/blogs/the_moss-pit/attachment/15062.ashx" length="483947" type="application/x-zip-compressed" /></item><item><title>Creating a Custom Action </title><link>http://suguk.org/blogs/the_moss-pit/archive/2008/10/31/14855.aspx</link><pubDate>Fri, 31 Oct 2008 17:09:00 GMT</pubDate><guid isPermaLink="false">19180fc3-a95d-4057-992e-fee77d73db0e:14855</guid><dc:creator>AussieNigel</dc:creator><slash:comments>3</slash:comments><comments>http://suguk.org/blogs/the_moss-pit/comments/14855.aspx</comments><wfw:commentRss>http://suguk.org/blogs/the_moss-pit/commentrss.aspx?PostID=14855</wfw:commentRss><description>&lt;div class="ExternalClassB4A2949D6CE2426AAEF0C4C623C07E50"&gt;&lt;font size="2" face="Tahoma"&gt;SharePoint
lets you customize just about anything, and one of the things I have
used in various features a few times is a custom action in the dropdown
menu for list items.  Here I will briefly go through how to define a
custom action in a feature.&lt;br&gt; &lt;br&gt;&lt;img alt="" src="http://www.thesug.org/blogs/moss-pit/MossPit%20Images/CustomActionSnap.JPG"&gt;&lt;br&gt;&lt;font size="1"&gt; &lt;br&gt;This
dropdown menu is known as the Edit Control Block (ECB), and it is one
of the many places SharePoint lets you define a custom action&lt;/font&gt;.&lt;br&gt; &lt;br&gt;In
this example, my feature will create a document library, and associate
a custom action with it.  Tthe action will allow a user to send the
document off to an email recipient to be reviewed.  It does this by
directing the browser to a custom layout page, and passing the library
and list item guid's in the querystring.  This page has controls on it
enabling the user to create and send an email, and it attaches a copy
of the document to it (Note: I haven't included the code for this
custom layout page in this posting - holler if you want it).&lt;br&gt; &lt;br&gt;The list and the custom action are defined in my feature's "Elements.xml":&lt;/font&gt;&lt;/div&gt;
&lt;div class="ExternalClassB4A2949D6CE2426AAEF0C4C623C07E50"&gt; &lt;/div&gt;
&lt;div class="ExternalClassB4A2949D6CE2426AAEF0C4C623C07E50"&gt; &lt;/div&gt;
&lt;div class="ExternalClassB4A2949D6CE2426AAEF0C4C623C07E50"&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;&lt;font size="2" color="#008000" face="Courier New"&gt; List instance deefinition &lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;--&gt;&lt;br&gt;&lt;font size="2" color="#800000" face="Courier New"&gt;ListTemplate&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#ff0000" face="Courier New"&gt;Name&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;=&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;ListNameGoesHere&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#ff0000" face="Courier New"&gt;Type&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;=&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;101&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#ff0000" face="Courier New"&gt;BaseType&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;=&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;1&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#ff0000" face="Courier New"&gt;OnQuickLaunch&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;=&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;False&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#ff0000" face="Courier New"&gt;FolderCreation&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;=&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;False&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#ff0000" face="Courier New"&gt;SecurityBits&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;=&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;11&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#ff0000" face="Courier New"&gt;DisplayName&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;=&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;List Display Name goes here&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#ff0000" face="Courier New"&gt;Description&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;=&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;List description goes here.&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#ff0000" face="Courier New"&gt;NoCrawl&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;=&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;True&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#ff0000" face="Courier New"&gt;AllowDeletion&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;=&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;True&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#ff0000" face="Courier New"&gt;DisallowContentTypes&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;=&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;False&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#ff0000" face="Courier New"&gt;DisableAttachments&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;=&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;False&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#ff0000" face="Courier New"&gt;DontSaveInTemplate&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;=&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;True&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#ff0000" face="Courier New"&gt;EnableModeration&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;=&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;False&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#ff0000" face="Courier New"&gt;MultipleTypes&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;=&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;False&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#ff0000" face="Courier New"&gt;Image&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;=&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;/_layouts/images/itdl.gif&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;&gt;&lt;br&gt;&lt;font size="2" color="#800000" face="Courier New"&gt;ListTemplate&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div class="ExternalClassB4A2949D6CE2426AAEF0C4C623C07E50"&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt; &lt;/font&gt;&lt;/div&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;
&lt;/font&gt;&lt;p class="ExternalClassB4A2949D6CE2426AAEF0C4C623C07E50"&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;&lt;font size="2" color="#008000" face="Courier New"&gt; Send Item for Review action &lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;--&gt;&lt;br&gt;&lt;font size="2" color="#800000" face="Courier New"&gt;CustomAction&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#ff0000" face="Courier New"&gt;Id&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;=&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;{9438f6c5-8074-4524-a73d-b605dda61243}&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#ff0000" face="Courier New"&gt;RegistrationType&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;=&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;List&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#ff0000" face="Courier New"&gt;RegistrationId&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;=&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;101&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#ff0000" face="Courier New"&gt;Location&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;=&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;EditControlBlock&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#ff0000" face="Courier New"&gt;Sequence&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;=&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;111&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#ff0000" face="Courier New"&gt;Title&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;=&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;Send Item for Review&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;&gt;&lt;br&gt;&lt;font size="2" color="#800000" face="Courier New"&gt;UrlAction&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt; &lt;br&gt;&lt;/font&gt;&lt;font size="2" color="#ff0000" face="Courier New"&gt;Url&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;=&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;{SiteUrl}/_layouts/ReviewItem.aspx?List={ListId}&lt;/font&gt;&lt;font size="2" color="#ff0000" face="Courier New"&gt;&amp;amp;&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;ID={ItemId}&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;"&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;/&gt;&lt;br&gt;&lt;font size="2" color="#800000" face="Courier New"&gt;CustomAction&lt;/font&gt;&lt;font size="2" color="#0000ff" face="Courier New"&gt;&gt;&lt;/font&gt;&lt;/p&gt;
&lt;div class="ExternalClassB4A2949D6CE2426AAEF0C4C623C07E50"&gt;&lt;font size="2" face="Tahoma"&gt;The
 element creates the document library to which the
action will be associated.  I am using the out-of -the-box document
library template here (101), but you could of course do the same thing
with a list instance based of your own list template.&lt;/font&gt;&lt;/div&gt;
&lt;div class="ExternalClassB4A2949D6CE2426AAEF0C4C623C07E50"&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div class="ExternalClassB4A2949D6CE2426AAEF0C4C623C07E50"&gt;&lt;font size="2" face="Tahoma"&gt;The settings I have specified in the  element are as follows:&lt;/font&gt;&lt;/div&gt;
&lt;div class="ExternalClassB4A2949D6CE2426AAEF0C4C623C07E50"&gt;
&lt;ul&gt;&lt;li&gt;&lt;font size="2" face="Tahoma"&gt;&lt;strong&gt;Id&lt;/strong&gt; - a Guid for this action&lt;br&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Tahoma"&gt;&lt;strong&gt;RegistrationType&lt;/strong&gt; - Specifies which type of object
this action will be associated to, in this case a list, though it could
be a file type, or content type, etc.&lt;br&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Tahoma"&gt;&lt;strong&gt;RegistrationId&lt;/strong&gt; - The identifier of the object specified above to link this action to.  In this case, the TemplateId of the list.&lt;br&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Tahoma"&gt;&lt;strong&gt;Location&lt;/strong&gt; - Where this custom action will be added
- in this case the ECB - though there are quite a few other places
where you can add a custom action.&lt;br&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Tahoma"&gt;&lt;strong&gt;Sequence&lt;/strong&gt; - The order in which the custom action(s)
will be displayed.  Presumably you could use this to put your action
lower in the list the the out-of-the-box ones, though I have only used
it to order my actions (if I have multiple ones) at the top of this
list.&lt;br&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Tahoma"&gt;&lt;strong&gt;Title&lt;/strong&gt; - the text to be displayed on your action&lt;/font&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;
&lt;ul&gt;&lt;li&gt;&lt;font size="2" face="Tahoma"&gt;&lt;strong&gt;UrlAction&lt;/strong&gt; - this is a sub-element of the
CustomAction element, and specifies the page where the browser will be
directed to when this action is triggered.  the URL I am redirecting to
uses a few SharePoint “tokens”. Windows SharePoint Services supports
the following tokens with which to start a relative URL:&lt;br&gt;&lt;br&gt;    - &lt;strong&gt;~site&lt;/strong&gt; - Web site (SPWeb) relative link.&lt;br&gt;    - &lt;strong&gt;~sitecollection&lt;/strong&gt; - site collection (SPSite) relative link.&lt;br&gt;&lt;br&gt;In addition, you can use the following tokens within a URL:&lt;br&gt;&lt;br&gt;    - &lt;strong&gt;{ItemId}&lt;/strong&gt; - Integer ID that represents the item within a list.&lt;br&gt;    - &lt;strong&gt;{ItemUrl}&lt;/strong&gt; - URL of the item being acted upon.&lt;br&gt;    - &lt;strong&gt;{ListId}&lt;/strong&gt; - GUID that represents the list.&lt;br&gt;    - &lt;strong&gt;{SiteUrl}&lt;/strong&gt; - URL of the Web site (SPWeb).&lt;br&gt;    - &lt;strong&gt;{RecurrenceId}&lt;/strong&gt; - Recurrence index. This token is not supported for use in the context menus of list items&lt;br&gt;&lt;/font&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;So, when the user selects my action “Send Item For Review”, it
will direct the browser to …/_layouts/ReviewItem.aspx, passing the list
ID and list item ID in the querystring. This page has controls on it
that allow the user to enter the email details, and send it off (with
the item attached) for review.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;&lt;br&gt;You can use custom actions all over the place - the ECB, the “Site Actions” menu, etc.  Further reading on custom actions: &lt;/font&gt;&lt;/div&gt;
&lt;ul&gt;&lt;li&gt;&lt;font size="2" face="Tahoma"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms460194.aspx"&gt;http://msdn.microsoft.com/en-us/library/ms460194.aspx&lt;/a&gt; &lt;br&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Tahoma"&gt;&lt;a href="http://blog.thekid.me.uk/archive/2007/06/23/sample-editcontrolblock-customaction-for-sharepoint.aspx"&gt;http://blog.thekid.me.uk/archive/2007/06/23/sample-editcontrolblock-customaction-for-sharepoint.aspx&lt;/a&gt;&lt;/font&gt;&lt;/li&gt;&lt;/ul&gt;&lt;font size="2" face="Tahoma"&gt;   -&lt;/font&gt;&lt;font size="2" face="Tahoma"&gt;
   -&lt;/font&gt;&lt;font size="2" face="Tahoma"&gt;
   -&lt;/font&gt;&lt;font size="2" face="Tahoma"&gt;
   -&lt;/font&gt;&lt;font size="2" face="Tahoma"&gt;
   -&lt;/font&gt;&lt;font size="2" face="Tahoma"&gt;
   -&lt;/font&gt;&lt;font size="2" face="Tahoma"&gt;
   -&lt;/font&gt;&lt;font size="2" face="Tahoma"&gt;
   -&lt;/font&gt;&lt;font size="2" face="Tahoma"&gt;
   -&lt;/font&gt;&lt;br&gt;&lt;font size="2" face="Tahoma"&gt;&lt;br&gt;Follo&lt;/font&gt;&lt;font size="2" face="Tahoma"&gt;wing a request in the comments for an example of the page&lt;/font&gt;&lt;font size="2" face="Tahoma"&gt; my custom action was passing to - I have *very quickly* cleaned this page of any customer specific information, and added it in the zip attached to this post.  It is simply an ASPX page and the code-behind (CS) file - the ASPX is deployed to a directory under TEMPLATE/LAYOUTS, and is referenced (as shown above) by the site action.  PLEASE NOTE: I have not checked if these would work following my quick cleaning, but think they are an adequate example of how you parse the URL to create objects for the given SPWeb / SPList etc.  Enjoy!&lt;br&gt;&lt;br&gt;&lt;/font&gt;&lt;img src="http://suguk.org/aggbug.aspx?PostID=14855" width="1" height="1"&gt;</description><enclosure url="http://suguk.org/blogs/the_moss-pit/attachment/14855.ashx" length="3273" type="application/zip" /></item><item><title>How to find out what alerts are queued to go by SharePoint </title><link>http://suguk.org/blogs/the_moss-pit/archive/2008/10/31/14854.aspx</link><pubDate>Fri, 31 Oct 2008 17:08:00 GMT</pubDate><guid isPermaLink="false">19180fc3-a95d-4057-992e-fee77d73db0e:14854</guid><dc:creator>AussieNigel</dc:creator><slash:comments>1</slash:comments><comments>http://suguk.org/blogs/the_moss-pit/comments/14854.aspx</comments><wfw:commentRss>http://suguk.org/blogs/the_moss-pit/commentrss.aspx?PostID=14854</wfw:commentRss><description>&lt;div class="ms-PostBody"&gt;&lt;div class="ExternalClass0F997D8C8E4D41EF8CAEFDAFDF9CE701"&gt;
&lt;div&gt; &lt;font size="2" face="Tahoma"&gt;Sometimes
it may not be possible to actually receive an alert email on your
system - maybe its a dev environment that doesn't support email, or
exchange might be throwing a hissy fit, or maybe you just don't want to
wait for the email to filter through to you.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;A friend from Microsoft, Brendan Griffin, gave me the following
SQL that shows the alerts that web app currently has queued to go. 
This SQL needs to be run against the WSS_Content database for the web
app which is expected to be producing the alerts:&lt;/font&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;
&lt;/font&gt;&lt;/font&gt;&lt;div&gt;&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;&lt;br&gt;SELECT&lt;/font&gt; &lt;br&gt;&lt;/font&gt;&lt;font size="2"&gt;   EventTime&lt;font color="#808080"&gt;,&lt;/font&gt; &lt;br&gt;   ItemName&lt;font color="#808080"&gt;,&lt;/font&gt; &lt;br&gt;   ItemFullUrl &lt;br&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;FROM&lt;/font&gt; &lt;br&gt;   &lt;/font&gt;&lt;font size="2"&gt;EventCache &lt;br&gt;&lt;font color="#0000ff"&gt;WHERE&lt;/font&gt; &lt;br&gt;   ID &lt;font color="#808080"&gt;&gt;&lt;/font&gt; &lt;font color="#808080"&gt;(&lt;/font&gt;&lt;font color="#0000ff"&gt;SELECT&lt;/font&gt; Id &lt;font color="#0000ff"&gt;FROM&lt;/font&gt; EventBatches&lt;font color="#808080"&gt;)&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2"&gt;&lt;font color="#808080"&gt; &lt;/font&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;
&lt;p&gt;&lt;font size="2" face="Tahoma"&gt;I tend to use this now when developing to determine if the alerts I expect are being created.&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font size="2" face="Tahoma"&gt;&lt;br&gt;&lt;/font&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;img src="http://suguk.org/aggbug.aspx?PostID=14854" width="1" height="1"&gt;</description></item><item><title>Problems Deleting Content Types - finding out where a Content Type is in use </title><link>http://suguk.org/blogs/the_moss-pit/archive/2008/10/31/14853.aspx</link><pubDate>Fri, 31 Oct 2008 17:07:00 GMT</pubDate><guid isPermaLink="false">19180fc3-a95d-4057-992e-fee77d73db0e:14853</guid><dc:creator>AussieNigel</dc:creator><slash:comments>0</slash:comments><comments>http://suguk.org/blogs/the_moss-pit/comments/14853.aspx</comments><wfw:commentRss>http://suguk.org/blogs/the_moss-pit/commentrss.aspx?PostID=14853</wfw:commentRss><description>&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;This
is something that can really have you pulling your hair out, but here
is a great little trick I found on Tyler Holmes's blog (&lt;a href="http://blog.tylerholmes.com/2008/02/deleting-content-types-in-sharepoint.html"&gt;http://blog.tylerholmes.com/2008/02/deleting-content-types-in-sharepoint.html&lt;/a&gt;).&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;I always seem to have trouble finding his posting again, so
thought I would stick it in here.  Point being, all credit for this
goes to Tyler.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;In order to delete a content type, it cannot be in use by any
lists in the site collection.  If it is, attempting to delete it will
show the incredibly helpful error message:&lt;/font&gt;&lt;/div&gt;
&lt;blockquote dir="ltr"&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;The content type is in use.&lt;/font&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;The following is Tyler's process for determining which lists in a site collection are using a particular content type:&lt;br&gt;&lt;br&gt;&lt;/font&gt;&lt;/div&gt;
&lt;hr&gt;


&lt;h4&gt;&lt;font size="2" face="Tahoma"&gt;Finding Lists/Libraries using the Content Type&lt;/font&gt;&lt;/h4&gt;
&lt;p&gt;&lt;font size="2" face="Tahoma"&gt;The first thing we'll need is access to the content database with a
SQL Client like SQL Management Studio. There's a tutorial on how to
connect &lt;a href="http://blog.tylerholmes.com/2008/02/accessing-wssmoss-content-databases.html" target="_blank"&gt;here&lt;/a&gt;.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Tahoma"&gt;We'll also need a tool like the &lt;a href="http://download.mondosoft.com/Ontolica/SharePointExplorer_V1_5_1_For_WSS3.zip" target="_blank"&gt;SharePoint Explorer for WSS 3.0&lt;/a&gt; (needs to be run on the WSS server itself) to figure out what the SiteCollection ID is.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Tahoma"&gt;Ok, lets get to it.&lt;/font&gt;&lt;/p&gt;
&lt;h4&gt;&lt;font size="2" face="Tahoma"&gt;Determining the Site Collection ID of your Site Collection&lt;/font&gt;&lt;/h4&gt;
&lt;ol&gt;&lt;li&gt;&lt;font size="2" face="Tahoma"&gt;Run the SharePoint Explorer (SPE) on the server that's hosting the WSS site. &lt;br&gt;&lt;br&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Tahoma"&gt;Find your Web Application with SPE and click on the &lt;strong&gt;Content Databases&lt;/strong&gt; tab to figure out what the name of the SQL Server instance hosting the content and what the name of the content database is. &lt;br&gt;&lt;br&gt;&lt;/font&gt; &lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Tahoma"&gt;Click on the Site Collection itself and grab the &lt;strong&gt;ID&lt;/strong&gt; property of the site, we'll need this when we run the stored procedure. &lt;br&gt;&lt;br&gt;&lt;/font&gt; &lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Tahoma"&gt;The last thing we'll need is the &lt;strong&gt;ContentTypeID&lt;/strong&gt; of
the content type we want to delete, the easiest way to get this is
right out of the URL when you go to delete (or edit) the content type (&lt;strong&gt;Site Settings&lt;/strong&gt;-&gt;&lt;strong&gt;Site Content Types&lt;/strong&gt;-&gt;Click on your content type). Here's a sample URL:&lt;br&gt;&lt;br&gt;&lt;a href="http://w2k3-tyler-virt/_layouts/ManageContentType.aspx?ctype=0x010700037B79D2DD41C24A8F55D82FC6B71FAC&amp;Source=http://w2k3-tyler-virt/_layouts/mngctype.aspx%20In"&gt;http://w2k3-tyler-virt/_layouts/ManageContentType.aspx?ctype=0x010700037B79D2DD41C24A8F55D82FC6B71FAC&amp;Source=http%3A%2F%2Fw2k3%2Dtyler%2Dvirt%2F%5Flayouts%2Fmngctype%2Easpx
&lt;br&gt;&lt;br&gt;In&lt;/a&gt; this example the &lt;strong&gt;Content Type ID&lt;/strong&gt; is:&lt;br&gt;&lt;br&gt;0x010700037B79D2DD41C24A8F55D82FC6B71FAC. &lt;br&gt;&lt;br&gt;&lt;/font&gt;&lt;/li&gt;&lt;li&gt;&lt;font size="2" face="Tahoma"&gt;Now we open up the SQL Server Management Studio, connect to the
[ServerName]\OfficeServers instance and run the following stored
procedure against our sites content database (we figured this out in
#2).&lt;br&gt;&lt;br&gt;&lt;/font&gt;
&lt;div class="code"&gt;&lt;font size="2" face="Tahoma"&gt;&lt;strong&gt;[proc_ListContentTypeInUse] [SiteCollectionId], [ContentTypeId]&lt;/strong&gt;&lt;br&gt;&lt;br&gt;Or in out case: &lt;br&gt;&lt;br&gt;&lt;strong&gt;[proc_ListContentTypeInUse] 'D2F8C831-4CA7-41C0-8497-82F897B61B2B', 0x010700037B79D2DD41C24A8F55D82FC6B71FAC &lt;/strong&gt;&lt;/font&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;&lt;font size="2" face="Tahoma"&gt;What you get back is a result set showing all the lists that the given ContentType is being used in.  If you go and remove the content type from all those lists you should be good to go and that pesky error message will go away.&lt;/font&gt;&lt;/p&gt;
&lt;hr&gt;

&lt;p&gt;&lt;font size="2" face="Tahoma"&gt;&lt;br&gt;This process has helped me a number of times!  Many thanks Tyler, and I hope you don't mind me plagarising your work here ;)&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;img src="http://suguk.org/aggbug.aspx?PostID=14853" width="1" height="1"&gt;</description></item><item><title>Creating an SPUser Object from a &amp;quot;Person&amp;quot; type list field</title><link>http://suguk.org/blogs/the_moss-pit/archive/2008/10/31/14852.aspx</link><pubDate>Fri, 31 Oct 2008 17:06:00 GMT</pubDate><guid isPermaLink="false">19180fc3-a95d-4057-992e-fee77d73db0e:14852</guid><dc:creator>AussieNigel</dc:creator><slash:comments>0</slash:comments><comments>http://suguk.org/blogs/the_moss-pit/comments/14852.aspx</comments><wfw:commentRss>http://suguk.org/blogs/the_moss-pit/commentrss.aspx?PostID=14852</wfw:commentRss><description>&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; 
I was quite suprised that creating an SPUser object from the
information contained in a "person" type list field is not
straight-forward.  After trying a few ways myself, I decided it was
time to hit the search engine.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;I found the solution on this Microsoft Forum discussion: &lt;a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3118673&amp;SiteID=1"&gt;http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3118673&amp;SiteID=1&lt;/a&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font size="2" face="Tahoma"&gt;The trick is, you must use the SPFieldUser classes to return the
object.  The code below shows how this is achieved (taken directly from
the discussion): &lt;/font&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face="Courier New"&gt;private SPUser GetSPUser(SPListItem item, SPField field)&lt;br&gt;{&lt;br&gt;    string currentValue = item[field.Title].ToString();&lt;br&gt;    SPFieldUser userField = (SPFieldUser)field;&lt;br&gt;    SPFieldUserValue fieldValue = (SPFieldUserValue)userField.GetFieldValue(currentValue);&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face="Courier New"&gt;    return fieldValue.user;&lt;br&gt;}&lt;/font&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;font size="2" face="Tahoma"&gt;&lt;br&gt;It all seems a little bit over-complicated to me, but this is
a function I have added to my Common.SharePoint library - no need to
have to re-solve the same problem at some time in the future....&lt;/font&gt;&lt;img src="http://suguk.org/aggbug.aspx?PostID=14852" width="1" height="1"&gt;</description></item></channel></rss>