Share this page

Saturday, May 16, 2009

Custom configuration section on the central administration of SharePoint 2007

In the last article published we were talking about how we can create a custom configuration section in the site setting Custom group section in site settings - WSS 3.0 y MOSS 2007, in the image 1 we can see this section created.

[Image 1]
clip_image002

In this article we are going to talk about how we will create a custom configuration section in the central administration of MOSS 2007 (Microsoft Office Sharepoint Server) and WSS 3.0 (Windows Sharepoint Services). The section will be in the Application Management tab of the Central Administration but we to create a custom section in other tab of Sharepoint, for example in Operation tab, the only thing that we need to do this is change the attribute location in the elements node and the base class of our custom page to inherits from OperationsPage, in the namespace Microsoft.SharePoint.ApplicationPages into the assembly Microsoft.SharePoint.ApplicationPages.Administration.dll
We are going to create a feature to create our custom section and install the page or pages with our code. The feature will be installed in the portal web where the central administration is running. In the image 2 we can see the feature activated in the portal web.

[Image 2]
clip_image004

Ok, let go to develop our custom configuration. The first thing that we are going to do is create a feature. I’m using Visual Studio 2008 and WSPBuilder templates. Once the feature was created we are going to change the elements.xml file to add our configuration into the node elements. In the section 1 we can see the complete source code to define our custom section and 2 options configurations.

[Section 1]

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomActionGroup
  Id="63418BE2-75A9-4fc2-88CC-21BBE7B3BB63"
  Title="Custom Administration Setting"
  Location="Microsoft.SharePoint.Administration.ApplicationManagement"
  Sequence="110">
  </CustomActionGroup>
  <CustomAction
  Id="F85ED83E-45DA-4467-9DA2-56F376BF7A88"
  Title="Configuracion 1"
  Location="Microsoft.SharePoint.Administration.ApplicationManagement"
  GroupId="63418BE2-75A9-4fc2-88CC-21BBE7B3BB63"
  Sequence="120"
  RequireSiteAdministrator="FALSE">
    <UrlAction Url="_admin/Siderys/CustomAdminSettings.aspx"/>
  </CustomAction>
  <CustomAction
  Id="E33599E2-E1C3-48c3-BCEB-9B36BD596C25"
  Title="Configuracion 2"
  Location="Microsoft.SharePoint.Administration.ApplicationManagement"
  GroupId="63418BE2-75A9-4fc2-88CC-21BBE7B3BB63"
  Sequence="130"
  RequireSiteAdministrator="FALSE">
    <UrlAction Url="_admin/Siderys/CustomAdminSettings.aspx"/>
  </CustomAction>
</Elements>


The first node that we need create is CustomActionGroup, this node defines our custom section and in the following table we can see the attributes that we need set.



· Id = A unique guid.



· Title = text that will be show.



· Location = section where we want create our custom section.



· Sequence = Numeric value.



The other 2 nodes will be CustomAction node and represent our configuration options. We can to more CustomAction node depending of the how many sections needed. In the following table we can see the attributes that we need set.



· Id = a unique guid.



· Title = text that will be show.



· Location = section where we want create our custom section.



· GroupId = If of the group section where we want show our custom configuration options. In this case we will add the id of our custom section



· RequireSiteAdministrator = If this option only can see by site administration then will be true if not false.



· UrlAction = Node inside the CustomAction node where we define the URL to the page.



Now we are going to create our custom configuration page. This page must inherit from ApplicationsManagementPage in the namespace Microsoft.SharePoint.ApplicationPages inside in the assembly Microsoft.SharePoint.ApplicationPages.Administration.dll. Our page will be installed in the admin folder (C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\ADMIN) because all page used in the central administration must be here. The path loaded in the attribute URL of the node UrlAction must start with _admin because this application in the IIS is mapped to the path C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\ADMIN where all pages and component to run the central administration were installed by Sharepoint.

In the image 3 we can see our custom section configuration in the central administration.



[Image 3]

clip_image006



In the image 4 we can see our custom page loaded when the user selected one of the options created in our custom section.



[Image 4]

clip_image008



Now we need compile the solution and to create the WSP package to install in Sharepoint. Remember that if we are using a WSPBuilder solution to create our project and feature. In the section 2 we can see the source code to create a batch installation file to add the WSP to sharepoint and active the feature. The only change that we must do is the variable URL and add the URL of our central administration.



[Section 2]



@echo off



set URL=http://<Servidor>/



set STSADM="C:\Program Files\Common Files\



Microsoft Shared\Web Server Extensions\12\BIN\stsadm.exe"



set SOLUTION_NAME= WspAddGroupSectionAdminSettings.wsp



set FEATURE_NAME= AddGroupAdminSetting



echo *



echo * Installing solution... '%SOLUTION_NAME%'



echo *



%STSADM% -o addsolution -filename %SOLUTION_NAME%



echo *



echo * Activating solution ... '%SOLUTION_NAME%'in %URL%



echo *



%STSADM% -o deploysolution -name %SOLUTION_NAME%



-url %URL% -immediate -allowGacDeployment -force



%STSADM% -o execadmsvcjobs



iisreset



rem ***********************************************



echo *



echo * Activating feature... '%FEATURE_NAME1%' in '%URL%'



echo *



%STSADM% -o activatefeature -name %FEATURE_NAME% -url



%URL% -force



echo *



echo * Install Completed.



echo *



You can download the complete source code form my SkyDrive.



clip_image009


Descargar Solución Completa con Instalador



Fabián Imaz

No comments: