title: Updating WebPart Properties using RunWithElevatedPrivileges in MOSS 2007
body: <p>As part of a MOSS 2007 solution, I've got a web part that displays a 'term' of the day. The terms are stored in a horribly messy XML file so it all gets parsed nicely and then is supposed to update a property called LastUpdatedOn to the current time.</p>
  
  <p>My problem is that administrator level accounts can see this with no problems whatsoever, but viewers are getting an error stating that they have insufficient privileges to save the properties of the web part.</p>
  
  <p>I'm running the code within an elevated privileges delegate, and have instantiated a new context to get around the fact that the context still thinks the current user is not the system account. </p>
  
  <p><a href="http://pastebin.com/m23120ce" rel="nofollow noreferrer">Pastebin of full code can be found here</a></p>
  
  <p>The problem lines are:</p>
  
  <pre><code>SaveProperties = true;
  LastUpdatedOn = DateTime.Now.ToString();
  </code></pre>
  
  <p>Commenting these out means that my web part works, but it will always display a random term on every page load instead of keeping the same term for 24 hours.</p>