Archive for the ‘MOSS2007’ Category

Web applications that use methods of the Microsoft.SharePoint.Administration namespace

Saturday, September 12th, 2009

Web applications that use methods of the Microsoft.SharePoint.Administration namespace, such as for creating or deleting sites and for global administrative customizations, require a different security validation. Add the following code to the .cs file in an application:

SPGlobalAdmin globalAdmin = new SPGlobalAdmin();
Context.Items[SPGlobalAdmin.RequestFromAdminPort] = true;
Page.RegisterHiddenField(”__REQUESTDIGEST”, globalAdmin.AdminFormDigest);

This security validation uses the AdminFormDigest property of the SPGlobalAdmin class to insert a message digest on the page in the browser, registering the digest as a hidden field through the RegisterHiddenField method of the System.Web.UI.Page class. In addition, the RequestFromAdminPort field specifies that the context of the request is through the administrative port.

Source:
http://epham.wordpress.com/2007/01/22/how-to-fix-security-validation-errors-in-sharepoint-aspnet-page/

System and Site masterpages

Saturday, September 12th, 2009

On this blog I read a clear explanation of site masterpages and system masterpages:
http://mysharepointworld.blogspot.com/2006/07/moss-2007-and-wss-30-master-page.html

Parameterize your page url to access SharePoint functionality

Tuesday, July 28th, 2009

Webpart maintenance page
Some people think they’re removing a webparts by clicking on ‘x’, actually the webpart is closed and stille exists (invisible) on the page. With the SharePoint webparts maintenance page you can close, remove or delete (multiple) webparts on a page. This is very handy page specially when your well written SharePoint webpart causes an error so the whole page can’t be displayed. Here is the solution to remove the blocking webpart, add the following to your page url: ?contents=1

Acces the SharePoint ToolPanes
Is it possible to edit forms pages like AllItems.aspx, DispForm.aspx EditForm.aspx …? Yes, add the following to you’re Forms page url ?ToolPaneView=2, now you can edit existing webparts or add new webparts, a content editor webpart with a disclaimer text for example. With ?ToolPaneView=3 you can search for webparts and with ?ToolPaneView=5 you can upload you’re custom webpart.

Do not use SharePoint Computed fields

Friday, January 16th, 2009

In this posting I will explain why not to use Computed fields. I was experiencing the following issue with the Computed field type:

I made a Computed column that combines two fields seperated with a minus sign:
 
<Field Name=”IDTitleField” Type=”Computed”>
   <FieldRefs>
      <FieldRef ID=”{GUID}” Name=”Title”/>
      <FieldRef ID=”{GUID}” Name=”ID”/>
   <FieldRefs>
   <DisplayPattern>
      <Column Name=”ID”/>
      <HTML><![CDATA[ - ]]></HTML>
      <Column Name=”Title”/>
   </DisplayPattern>
</Field>

After creating the column you can see the column at the site collection columns. You can add the column to you’re site collections contenttypes. But when you add the contenttype to a list the Computed columns are not copied(!) to the list. Why the Computed fields are not copied I don’t know.

So I start using the Calculated field with the following:

<Field Name=”IDTitleField2″ Type=”Calculated” ResultType=”Text”>
   <FieldRefs>
      <FieldRef ID=”{GUID}” Name=”Title”/>
      <FieldRef ID=”{GUID}” Name=”ID”/>
   <FieldRefs>
   <Formula>=CONCATENATE(ID, ” - “, Title)</Formula>
</Field>

This Calculated field solved my issue. Because the calculated fields are copied when adding the contenttype (which contains the Calculated field) to the list! So my conclusion is to avoid using the Computed field type. Therefore you can use the Calculated field type in many cases.

SharePoint Search did you mean?

Thursday, October 30th, 2008

When you make a mistype in the Search box. SharePoint is giving a message “did you mean:” or “bedoelde u:” for a dutch site collection. These suggestions are given in the first occurrence of the browser languages. Very strange from Microsoft to use the browser language for this. Imagine that you have the first browser language set to en-us and you search in a dutch site collection for ’succes’:

Then SharePoint comes with the following message: “Bedoelde u? Success”. So be aware for this strange behaviour!

SharePoint language problem with search scopes groups

Thursday, October 30th, 2008

When you have an english installation of SharePoint and you install the language packs (wss en sharepoint) for example the dutch language. You get the possibility to create dutch site collections. Sometimes when you create a dutch site collection you get errors with search. I didn’t see the searchscope dropdown but only the words ‘All sites’. When I searched for something I got the following javascript error:
‘options is leeg of geen object’.

The reason for this is that I couldn’t select a searchscope because they were not available. So I visited the  Scopes at the site collection level here:
http://SITE_COLLECTION/_layouts/viewscopes.aspx?mode=site

There I saw that the scope display groups has an english title. English titles in a dutch site collection? That is strange so I googled and found the following:
http://patrikluca.blogspot.com/2008/02/all-sites-search-scopes-missing-in.html

After reading this I renamed the scope display groups into:
Vervolgkeuzelijst voor zoeken
and
Geavanceerd zoeken

After this change the scopes dropdown is shown and search will work!

Updated web.config modification manager for SharePoint

Thursday, October 30th, 2008

I downloaded the Web.config modification manager for SharePoint written by Vincent Rothwell from:
http://blog.thekid.me.uk/archive/2007/03/24/web-config-modification-manager-for-sharepoint.aspx

It is a nice add-in for the central admin. The tool manages all the web.config modifications that are done with the SPWebConfigModification class.

For our customer I need some more functionality like:
- adding modifications with the type EnsureSection;
- updating the current modifications;
- display the active modifications (the latest modification with the highest sequence);
- fix that the tool also works in complex farm scenario’s:
            SPFarm.Local.Services.GetValue<SPWebService>().ApplyWebConfigModifications();
changed that into:
            oApp.Farm.Services.GetValue<SPWebService>().ApplyWebConfigModifications();
(Because Local.Services can not access the other machines? I read about this somewhere on the internet)

Here you can download my update of the webconfig.aspx. Simply add the file to the following folder:
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\ADMIN

This folder contains the application pages for the central admin. You can visit the page easily by visiting the following url: http://CENTRALADMIN:PORT/_admin/webconfig.aspx

Vincent Rothwell has also a version with a Solution installer (by Lars Fastrup) with a Custom Action that adds the file to the Central Administration > Application Management page.

Hope this helps you with controlling the web.config modifications.

FeatureReceivers needs GAC

Wednesday, August 20th, 2008

On many websites you read about installing FeatureReceiver assembly inside the Global Assembly Cache (GAC) instead of placing the assembly inside you’re web application bin folder. In this post I will explain why it is necessary to use the GAC.

Inside a SharePoint webapplication on site collection level or site level you can activate and deactivate features. If you activate a feature in this context and you’re assembly is located in the web application bin folder everything will be fine. The assembly can be found because you’re inside the context of you’re web application that has the dll (in the bin folder). The .Net framework checks the GAC first, when the assembly cannot be found in the GAC, the local bin folder is checked. So the assembly can be found in this situation.

But when you decide to activate you’re feature from STSADM command or you’re feature will be activated by another site definition feature which contains FeatureActivation dependency, the feature will be activated from within the Central Admin by creating a site collection. In both scenarios the context is different. So the .Net framework checks the GAC first and will find no assembly in the GAC. After the GAC the local bin folder (from stsadm or Central Admin web application) is checked and the assembly cannot be found there. Because the assembly resides in the bin folder of you’re web application.

This is the message you get:
System.IO.FileNotFoundException: Could not load file or assembly '<assembly>' or one of its dependencies. The system cannot find the file specified.

SOLUTION:
Put all you’re FeatureReceiver assemblies in the GAC.

Very slow STSADM commands…

Wednesday, August 20th, 2008

As a SharePoint 2007 developer you have to use the stsadm command line tool to add a solution to the SharePoint solution store. You can do this with the following command:

stsdm -o addsolution -filename <the name of your solution (*.wsp) file>

This simple command takes up to 15 seconds on my development server. So I tried a simple stsadm command without parameters. And this command also takes 15 seconds.

I realised me a situation that the stsadm command was ready in 1 second. So I thought maybe it has something to do with the internet connection. (Because my development server is disconnected from internet)

I started googling and found this: “When you use authenticode signed assemblies in an application, the application needs to go out and check the certificate revocation lists (CRLs) to verify that the signature is still valid the first time it loads up the authenticode signed assembly. If the server, serving your asp.net application, doesn’t have internet access or if the internet connection is slow this can lead to issues where you stall the process during startup or when the assembly in question first loads.”

My experience in a disconnected scenario is that not only the first time the assemblies loads slow. It loads always slow, because the CRLs cannot be found and the network timeout is reached. Behind a firewall or proxy the stsadm commands are 2 times slower! The commands will always take place after the timeout period. So why should we wait for that?! 

For more information read the article:
http://blogs.msdn.com/tess/archive/2008/05/13/asp-net-hang-authenticode-signed-assemblies.aspx

SOLUTION:
The solution is to avoid checking the CRLs by adding the following code to the machine.config:

<configuration>
    <runtime>
        <generatePublisherEvidence enabled=“false”/>
    </runtime>
</configuration>

Be sure you have .Net Framework 2.0 SP1 installed. 

For more information about the hotfix visit the following website:
http://support.microsoft.com/default.aspx/kb/936707

Visual Studio 2008 Extensions, Version 1.2

Tuesday, June 10th, 2008

If you’re using Windows XP you can’t install this version of Visual Studio 2008 Extensions, because you don’t have Windows SharePoint Services 3.0 installed:

image

Here I read a solution to let you’re computer act as it has WSS 3.0 installed:
http://blogs.msdn.com/jannemattila/archive/2007/08/16/how-to-install-windows-sharepoint-services-3-0-tools-to-xp-or-vista.aspx

1. Start regedit

2. Add the key: [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\12.0] 

3. Add the value: “Sharepoint”=”Installed”

image

After that, download the software and install it:
Windows SharePoint Services 3.0 Tools: Visual Studio 2008 Extensions, Version 1.2