Thursday, December 24, 2009

Using SharePoint Term Stores

In the new SharePoint 2010 Managed Metadata feature (a.k.a. Managed Metadata Service [MMS]), all taxonomy data is stored within a SQL Server database called the term store. Creating a managed service application will create a term store that you can use to build your taxonomy hierarchy within, or as it reads on TechNet, “A managed metadata service publishes a term store and, optionally, content types; a managed metadata connection consumes these.”

When you install SharePoint 2010, a managed metadata service called “Managed Metadata Service” is created for you. This term store maps to a SQL DB that begins with the same name.

image
- Managed Metadata Service DB in SQL Server

However, if you go to the Term Store Management Tool (through Central Administration or Site Settings), you’ll find that you don’t have any options to create or manage terms. The reason for this is that you need to add yourself to the administrators group for the managed metadata service.

image
- The Term Store Management Tool without any administrators

After you add yourself and save the changes, you’ll be able to create groups, term sets and terms.

image
- Once you add your admins, you can start to use the term store

At this point, you can try to tag SharePoint content. If you open a list and try to tag something, and you see the message, “This control is currently disabled. You might not have the right permission level to use this, you might need to select an object or item, or the content might not work in this context,” then you either have a rights issue, or another problem with your server.

image
- Tagging control disabled in the ribbon

Creating Your Own Term Store

If you want to create your own term store, you’ll need to follow the steps below to create a new managed metadata service. Creating a SharePoint 2010 Managed Metadata Term Store is covered on TechNet, but I’ll be delving into Managed Metadata development in a future post, so I figure I should cover the basics as well.

1. First you’ll need to open SharePoint 2010 Central Administration and select Manage Service Applications from the Application Management section.

ManagedService1

2. At this point, the Service Applications tab should be selected at the top of the page. Next, click the dropdown arrow under New and and click on Managed Metadata Service.

ManagedService2b

3. This opens the Create New Managed Metadata Service dialog.

ManagedService5

The fields in this dialog are:

Name: This is simply the name of your new managed metadata service.

Database Server: Name of your database server.

Note from Microsoft: “If you are using SQL Express, do not change the default value of <machine name>\SharePoint. ”

Database Name: The database on the selected server you wish to use. If the DB does not exist, it will be created.

Note from Microsoft: “The only way to obtain the name of a database if you have deleted the managed metadata connection to the database is by using SQL Server Management Studio.”

Database authentication: The recommended option is Windows authenticated, but SQL authentication is also available.

Failover Database Server: If you’re using a failover DB server, you can enter it here.

Web Application Pool: You can either create a new pool or choose an existing one from the dropdown menu. Note: Ensure that the selected application pool is actually running before you try to use your term store.

Content Type Hub: From Microsoft: “If you want the managed metadata service to provide access to a content type library as well as to a term store, type the URL of the site collection that contains the content type library in the Content Type hub box. The service will share the content type library at the root of the site collection.”

There are also two checkbox options at the bottom:

- Report syndication import errors from Site Collections using this service application

Note from Microsoft: “When another Web application imports the content types that this service shares, the import process might generate errors. To record these errors in the error log of the site collection that is exporting (as well as to the error log of the site collection that is importing), select Report syndication import errors from Site Collections using this service application.”

- Add this service application to the farm’s default list

Note from Microsoft: “The service is automatically added to the Default proxy group for the farm. To have a connection to this service created automatically when a new Web application is added to the farm, select Add this service application to the farm’s default list.”

From the same area of central admin, you have the option to perform numerous other operations on your term store. For example, delete a term store, modify the term store permissions, add term store administrators, etc.

image
- The ribbon offers more term store management options

Here’s some quick and dirty code to check the term stores available on your server:

using (SPSite site = new SPSite("http://localhost/%22))
{
//Instantiates a new TaxonomySession for the current site.
TaxonomySession session = new TaxonomySession(site);

foreach (TermStore termstore in session.TermStores)
{
Label1.Text += "\n" + termstore.Name.ToString();
}
}

SharePoint Managed Metadata (Taxonomy) Posts:

SharePoint Taxonomy Part One – Introduction to SharePoint Managed Metadata
SharePoint Taxonomy Part Two – End-User Experience
SharePoint Taxonomy Part Three – Administrator Experience
(including Using SharePoint Term Stores and SharePoint Taxonomy Hierarchy)
SharePoint Taxonomy Part Four – Developer Experience
(including SharePoint 2010 Visual Web Parts and SharePoint 2010 Taxonomy Reference Issues)

Managed Metadata Best Practices from Microsoft:

Plan managed metadata (SharePoint Server 2010)
Managed metadata overview (SharePoint Server 2010)
Managed metadata service application overview (SharePoint Server 2010)
Managed metadata roles (SharePoint Server 2010)
Plan terms and term sets (SharePoint Server 2010)
Plan to import managed metadata (SharePoint Server 2010)
Plan to share terminology and content types (SharePoint Server 2010)

[Disclaimer: This information is based on SharePoint 2010 Beta 2 and may differ from the RTM build.]

1 comment:

Sameer Dhoot said...

Stephen,

Have you setup Managed Metadata Service using SQL Auth with SQL Server not in Domain(or untrusted domain). I am trying to setup using SQL Auth but I think its not possible though it creates the database during creation of the service application with specified SQL Auth parameters, it fails at point where it tries to add the Windows/NT account which I used for Application Pool. Following are line from my ULS Log:

Granting user 'MYDOM\spsvcapp' access to database 'SQLDB-ND.SP-SvcApp-ManagedMetadataDB'. bdc3551c-c8ef-409b-be38-b49094698b84
System.Data.SqlClient.SqlException: Windows NT user or group 'NET\svc_spsvcapp' not found. Check the name again. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) at System.Data.Sql... bdc3551c-c8ef-409b-be38-b49094698b84

Sameer Dhoot | http://sharemypoint.in