Using OM to access Lists in another web app / Random Notes

I had to access a list on a SharePoint web app from another web app on the same farm using code, but experienced a sql exception. The app pool accounts had least privilege, but the accounts of the user had restricted reader rights to both web apps (and app pool account as i tried running with elevated privileges). It turns out that if your executing code against a web app outside of your current context, you need to have rights to the db on the server.

I ended up reading via webservices and converting to a datatable, similar to the following.

Unrelated, here is a good article on making web.config mods via a feature receiver.

Here is another unrelated article about group policy (something i never fully remember).

C#: What threads are custom controls running in

Here’s a useful (well maybe) block of code to determine what thread controls are running in.

Note that this code was placed in a base class (hence the 1s on the stack frame to show callers etc).

protected override void CreateChildControls()
  var stack = new StackTrace();
  var message = string.Format(
    “THREAD ID: {0}, CLASSNAME: {1}, METHOD: {2}”,

Notes: My Current Workstation Configuration

I am running windows 7 as my main environment, however i have a need to run Windows Server 2008 R2 64-bit as well. In addition my Windows 7 environment needs to run Bitlocker. Virtual PC does not support 64-bit operating systems.

The approach I took was to use the Boot to VHD feature of Windows 7 and run VHDs from a new partition on my main HD, (so bitlocker can still be enabled on my Windows 7 partition). I could have run traditional due boot from a partition, but in doing so would loose the benefits of easily being able to backup.

Steps to do this were:

  1. Launch “Computer Management”
  2. Select storage->disk management
  3. Shrink the relevant drive to create space for the new partition
  4. Right click unallocated space (from shrink) and create a “New Simple Volume”. Make sure the file system for this is set to NTFS (note that Bitlocker must not be applied to this volume).
  5. Shut down windows and boot into Windows Server 2008 R2 DVD.
  6. At “install now” click the “repair your computer” option, don’t select a installation and select the command prompt (alternatively press shift + F10).
  7. At the command prompt run Diskpart
  8. Run create vdisk file=”V:\server2008.vhd” type=”fixed” maximum=30000 (where V is the name of your partition).
  9. Run select vdisk file=”V:\server2008.vhd”
  10. Run attach vdisk 
  11. Exit the console window and click x to close the dialog.
  12. Run through the Server 2008 installed and install to the newly created vhd (which will show as a partition).
  13. Once installed, you will now see the boot menu with both operating systems.

Note that when you want to delete / reattach VHDs use bcdedit as per


Related links: