SharePoint Development: Custom Web Part Settings

This post briefly covers how to create custom web part settings in your Visual Studio solution.

In the main webPart.CS file add the following settings:

 // Custom WP Setting – English RSS URL

 [Personalizable(PersonalizationScope.Shared),

 WebBrowsable(true),

 WebDisplayName(“English RSS URL”),

 WebDescription(“Enter the English RSS URL”),

 Category(“Custom Web Part Settings”)]

 publicstring ENRSSUrl { get; set; }

 // Custom WP Setting – English RSS URL

 [Personalizable(PersonalizationScope.Shared),

 WebBrowsable(true),

 WebDisplayName(“French RSS URL”),

 WebDescription(“Enter the French RSS URL”),

 Category(“Custom Web Part Settings”)]

 publicstring FRRSSUrl { get; set; }

 Update the createChildControls method:

protected override void CreateChildControls()

{

 Control control = Page.LoadControl(_ascxPath);

 // Reference public properties in visual webpart control

 VisualWebPart1UserControl vswebcontrol = control asVisualWebPart1UserControl;

 // Pass through the values to the web part control

 vswebcontrol.toolPartENRSSUrl = ENRSSUrl;

vswebcontrol.toolPartFRRSSUrl = FRRSSUrl;

Controls.Add(control);

}

Reference the settings in the main web part control class:

public partialclass VisualWebPart1UserControlUserControl

 {

 // Public Properties

 public string toolPartENRSSUrl { get; set; }

 public string toolPartFRRSSUrl { get;set; }

 // Internal strings

 string ENURL = string.Empty;

 string FRURL = string.Empty;

 protectedvoid Page_Load(object sender, EventArgs e)

{

 // Set the string values

ENURL = toolPartENRSSUrl;

FRURL = toolPartFRRSSUrl;

 // Reference the custom web part settings

lblEN.Text = ENURL;

LblFR.Text = FRURL;

}

}

It’s as simple as this !

SharePoint 2010 – Profiles missing from import

Today I came across a very odd issue where I had seen a number of missing SharePoint User Profiles missing from the Active Directory synchronization.

The problem was, the deleted Active Directory users were left in the User Profile database marked as deleted, but never deleted by the “My Site Cleanup Job”. You can query the UserProfile_Full table to determine which profiles have the bdeleted column set to 1.

A description of the timer job is displayed below:

It turned out that the solution was to ensure a My Site host had been configured as part of the farm setup, so that the missing profiles from import are correctly removed. The My Site Cleanup Job runs every hour,  by default, and even though the job looked as though it ran successfully it wasn’t actually performing the specified function.

You can follow this Microsoft TechNet Article to configure a My Site Host in your farm.

SharePoint Server 2010: Service Application Error

I recently came across an issue where I was unable to manage the SharePoint Service Applications within Central Administration. The error I received was as follows:

“The specified user or domain group was not found”

This symptom was caused by a user account which was removed from Active Directory, that was assigned to a Managed Metadata Service Application. The account in question was assigned administrator rights in the service application. I worked woth Microsoft to remedy the issue in my case after performing some initial steps to determine which service application was causing the problem.

To determine the problem, I first had to find out which service application was causing the message to appear. I followed these steps:

1 – Opened IIS Manager

2 – Navigated to Sites -> SharePoint Web Services

3 – Each Service application has a guid and in the basic properties, you can review the path of the web service to identify the service.

4 – The SharePoint diagnostic logs should correlate to the application ID with the error in question, and so should the application event logs.

5 – When you determine which service application is causing the issue, you can run the following SQL statement against your SharePoint configuration database (I used %Metadata%, as I was aware it was the Metadata Service application):

SELECT [Name], [Version], CAST([Properties] as xml)

From [SharePoint_Config].[dbo].[Objects] with (nolock)

Where [Name] LIKE ‘%Metadata%’

6) Click the properties column XML result and review the following sections:

<sFld type=”Stringname=m_SerializedAcl>

7 – There should be some identities associated with the service application.

8 – Check each Identity Name in Active Directory to determine which one was removed.

8 – In some cases you should be able to re-create the account in Active Directory, since the service application is looking for a principle name, and not a SID. Ensure you synchronize your Active Directory Domain.

9) You should now be able to navigate to the service applications (providing the particular service application is looking for a principle name in Active Directory), and then remove the account from the service application permissions.

10) If the above solution does not work, you can create a new account, with a different name, and try the following stsadm command:

stsadm -o migrateuser -oldlogin {the domain\old users login name that was removed} -newlogin {the domain\new AD account} -ignoresidhistory

e.g. stsadm -o migrateuser -oldlogin corp\deleteduser -newlogin corp\newuser -ignoresidhistory

You can also use the SharePoint Management Shell if you prefer and use the Move-SPUser command.

Should the above remedy not work in your situation, I highly recommend logging your particular case with Microsoft Premier Support to resolve your issue.

I also highly recommend not to make any direct changes to the SharePoint configuration database via custom code or SQL statements, in order to keep a  supported SharePoint environment.

SharePoint 2010 Training – Creating a Custom Content Type

I have recently created a training video which I would like to share, on how to create a custom content type in Microsoft SharePoint Server 2010. The video covers the following training:

1) Creating a SharePoint Site
2) Creating a Car Manufacturers List
3) Creating a Car List
4) Creating a Content Type
5) Assigning the Content type to the Car List

I welcome your feedback and I will start to add more training videos to this blog in the future.

Microsoft Releases SharePoint 2010 Service Pack 1

Microsoft has released SharePoint 2010 Service Pack 1.

The details of the release can be found here.

Download the Service Pack here.

Service Pack 1 for SharePoint 2010 on its way soon (June 2011)

Review the new features SharePoint 2010 SP1 here on the Microsoft  SharePoint Team Blog: http://sharepoint.microsoft.com/blog/Pages/BlogPost.aspx?pID=973

Microsoft SharePoint 2010 Administration Toolkit 2.0

For any SharePoint 2010 implementation, I highly recommend this Toolkit which is available here: http://www.microsoft.com/downloads/en/details.aspx?FamilyId=718447d8-0814-427a-81c3-c9c3d84c456e&displaylang=en

SharePoint 2010 Virtualized Infrastructure

Recently one of my colleagues discussed SharePoint Infrastructure sizing with me and we were discussing Virtualizing an entire farm. There are a number of factors that need to be considered which I will update here regularly.

This blog is intended to send you directly to the relevant information for planning, design and implementation.

Starting Point

It is important to understand the basics first prior to moving ahead with your deployment. These articles and references are a good starting point to review:

There is no doubt that SharePoint can run on a virtualized platform. I would recommend reviewing this KB for planning your virtualized SharePoint 2010 environment: http://technet.microsoft.com/en-us/library/ff607968.aspx

Here is Microsoft’s support policy for Microsoft Software running on non-Microsoft hardware http://support.microsoft.com/kb/897615

Reference this KB to review which Microsoft Products are supported in a virtualized environment: http://support.microsoft.com/kb/957006

Since I am only discussing Hyper-V on my blog, you can review the Hyper-V Planning guideance on TechNet here: http://technet.microsoft.com/en-us/library/ee344841(WS.10).aspx

Hyper-V Getting Started Guide: http://technet.microsoft.com/en-us/library/cc732470(WS.10).aspx

It is important to review the SVVP: http://www.windowsservercatalog.com/svvp.aspx?svvppage=svvp.htm

Infrastructure Planning

Apart from the solution, Infrastructure Planning is one of the the most important components to get right. The core reason is the investment made in server and network infrastructure will likely be based on a 3-5 year replacement plan.

Performance

Important references for Performance tuning :

  1. Windows 2008 R2 Performance Tuning Guide: http://msdn.microsoft.com/en-us/windows/hardware/gg463392.aspx
  2. Troubleshooting Performance tuning problems in SQL Server 2008   http://msdn.microsoft.com/en-us/library/dd672789.aspx

SharePoint Server 2010 Service Applications

The architecture in SharePoint 2010 has completely changed from its predecessor, Microsoft Office SharePoint Server 2007 (MOSS). In the previous version of SharePoint a Shared Services Provider (SSP) was used to provide services for a group of applications which were associated to a SSP. These included the following services:

  • Office SharePoint Server Search: Necessary to crawl web applications in order to index content into a single index.
  • Excel Services: Used to provide access to Excel workbooks in trusted data connection libraries
  • My Sites: Provide a method for web applications to leverage the mysite functionality
  • Usage Data: A Central location to store site usage data
  • Business Data Catalog: A schema for stored business data

A web application in this case would only be associated with one SSP.

In SharePoint Server 2010 the architecture has been redesigned to be far more flexible and scalable. The ‘Service Applications’ are now what make up the above Shared Services with some additional services included in the new version. These are as follows:

 (Read the full TechNet article here: http://technet.microsoft.com/en-us/library/cc560988.aspx)

Access Services Lets users view, edit, and interact with Access 2010 databases in a Web browser.
Business Data Connectivity service Gives access to line-of-business data systems.
Excel Services Application Lets users view and interact withExcel 2010 files in a Web browser.
Managed Metadata service Manages taxonomy hierarchies, keywords and social tagging infrastructure, and publish content types across site collections.
PerformancePoint Service Application Provides the capabilities of PerformancePoint.
Search service Crawls content, produces index partitions, and serves search queries.
Secure Store Service Provides single sign-on authentication to access multiple applications or services.
State service Provides temporary storage of user session data for SharePoint Server components.
Usage and Health Data Collection service Collects farm wide usage and health data, and provides the ability to view various usage and health reports.
User Profile service Adds support for My Site Web sites, profile pages, social tagging and other social computing features.
Visio Graphics Service Lets users view and refresh published Visio 2010 diagrams in a Web browser.
Web Analytics service Provides Web service interfaces.
Word Automation Services Performs automated bulk document conversions.
Microsoft SharePoint Foundation Subscription Settings Service Provides multi-tenant functionality for service applications. Tracks subscription IDs and settings for services that are deployed in partitioned mode. Deployed through Windows PowerShell only.

 

The farm services are now far more extensible and scalable and can be shared with other farms via service application proxies.

I’ll be writing more about service applications in future posts.