Monthly Archives: August 2005

Google – Lords of the web!

I know it is a somewhat sweeping statement, but it is my opinion that Google are one of the finest software companies out there right now. Not only is their “vanilla” search engine relied upon by web-heads worldwide, there are some very neat extras that they have released recently.

Google Suggest (Beta) uses XMLHTTPRequests to pre-empt what you are searching for.

GMail is their killer mail app.

Google Talk is their new baby – an IM system that aims, eventually, to be able to talk to most systems, unlike proprietary offerings like MSN Messenger.

Google Deskbar is a great way to be able to access the power of Google’s search engine without having to fire up a browser. In adition, you can specify your own search paths. For example, I have set it up to be able to search Technorati as well as the default search engines.

Picasa lets you organise your photo collection.

Google Maps and Google Earth are excellent mapping and satellite imagery apps. The comedy offshoot of Google Earth is Google Moon (Try zooming right in!)

I almost hate to say this, but I’m not sure I could go back to life without my Google tools and toys.

Sharepoint portal connection strings

How to pull connection string details out of a Sharepoint portal site.

using System;
using Microsoft.SharePoint.Portal;
using Microsoft.SharePoint.Portal.Topology;

namespace SPConnStrings
{
  ///
  /// Summary description for Class1.
  ///
  class Class1
  {
    ///
    /// The main entry point for the application.
    ///
    [STAThread]
    static void Main(string[] args)
    {
      //
      // TODO: Add code to start application here
      //
      TopologyManager topology = new TopologyManager();
      PortalSite portal = topology.PortalSites[new Uri("http://cleanportal")];
      Console.WriteLine("Site db :: " + portal.SiteDatabase.SqlConnectionString.ToString());
      Console.WriteLine("Profiles db :: " + portal.UserProfileDatabase.SqlConnectionString.ToString());
      Console.WriteLine("Services db :: " + portal.ServiceDatabase.SqlConnectionString.ToString());
      Console.ReadLine();
    }
  }
}

Sharepoint permissions and web parts

There is a strong argument against doing things like this, but there are times when you just have to bite the bullet and grant full access permissions to certain web parts without having to install them to the GAC. Here’s how.

The first requirement for this method is that your web parts must be strong named. I would recommend creating a new keyfile specifically for web part assembl
ies that you want to fully trust. Use the following command to do so.

sn.exe -k c:\keyfiles\FullTrustWebParts.snk

Apply this key file in the AssemblyInfo.cs file for your web part project

[assembly: AssemblyKeyFile(@"c:\keyfiles\FullTrustWebParts.snk")]

Build and deploy your project as normal.

Now for the fun part – configuring Sharepoint to accept the signed web parts as fully truted.

In the folder C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\CONFIG copy your wss_mediumtrust.config file to wss_trustsigned.config and then open the new file for editing.

Find the section that starts with the following

<codegroup class="FirstMatchCodeGroup" version="1" PermissionSetName="Nothing"> <imembershipcondition class="AllMembershipCondition" version="1" /&gt

and add the following immediately after this code

<codegroup class="UnionCodeGroup" version="1" PermissionSetName="FullTrust"> <imembershipcondition class="StrongNameMembershipCondition" version="1" PublicKeyBlob="...see note below..." /> </codegroup>

The test “…see code below…” needs to be replaced with the public key blob from your assembly. To find this string, use the following command

secutil.exe -hex -s <path to assembly>

Important : remove the leading 0x from this string

Save and close the new file.

Next, open up the Web.Config file from the root of your Sharepoint site. In my case, this resides at c:\inetpub\wwwroot\intranet\web.config

In this file, find the “securityPolicy” section. Copy one of the “trustLevel” nodes, and change the “name” attribute to “wss_trustsigned”, and also the policyFile attribute to reflect the path to your new policy file (ie. C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\CONFIG\wss_trustsigned.config)

Once you have added the policy setting, you will need to find the “trust” node within the “system.web” section. Change the value of the “level” attribute to “wss_trustsigned”. This is the value you set in the previous step.

Now save the file, and restart IIS. Your web parts should be fine now.

*NOTE* this has not been tested step by step from these instructions. I will chek it all this week, given the chance, and make any changes that might be necessary. I’m afraid that this is due to having to try to remember what a colleague did 12+ months ago. Ho-hum.