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.

http://blog.krichie.com/2008/09/11/unrestricted-access-via-sharepoint-object-model-from-console-applications/

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

http://politechnosis.kataire.com/2008/09/reading-sharepoint-lists-into-adonet.html

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

http://weblogs.asp.net/wesleybakker/archive/2009/01/21/web.config-modifications-with-a-sharepoint-feature.aspx

Here is another unrelated article about group policy (something i never fully remember).
http://technet.microsoft.com/en-us/library/cc732593(WS.10).aspx

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(
    CultureInfo.InvariantCulture,
    “THREAD ID: {0}, CLASSNAME: {1}, METHOD: {2}”,
    Thread.CurrentThread.ManagedThreadId,
    stack.GetFrame(1).GetMethod().ReflectedType.FullName,
    stack.GetFrame(1).GetMethod().Name);
  Debug.WriteLine(message);
}

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 http://thelazyadmin.com/blogs/thelazyadmin/archive/2009/01/12/windows-7-boot-from-vhd.aspx

 

Related links: