Navigate to the Central Administration. Click on Application Management.
Click on Manage service applications which is available under Service
Applications. Click on MMS (Managed Metadata Service) which has the following
term store
Steps Involved:
- Open Visual Studio 2012 (Run as administrator).
- Go to File=> New => Project.
- Select Console Application in the Visual C# node from the installed
templates.
- Enter the Name and click on OK.
- In the solution explorer, right click on References folder and then
click on Add Reference.
- Add the following assemblies from 15 hive (C:\Program Files\Common
Files\microsoft shared\Web Server Extensions\15\ISAPI).
- Microsoft.SharePoint.Client.dll
- Microsoft.SharePoint.Client.Runtime.dll
- Microsoft.SharePoint.Client.Taxonomy.dll
- Open Program.cs file and replace the code with the following
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Threading.Tasks;
using
Microsoft.SharePoint.Client;
using
Microsoft.SharePoint.Client.Taxonomy;
namespace
ManagedMetadataClient
{
class
Program
{
static
void
Main(string[]
args)
{
// ClienContext - Get the context for the SharePoint Site
// SharePoint site URL - http://c4968397007/
ClientContext clientContext =
new
ClientContext("http://c4968397007/");
// Get the TaxonomySession
TaxonomySession taxonomySession =
TaxonomySession.GetTaxonomySession(clientContext);
// Retrieve all the term stores (Name property alone)
clientContext.Load(
taxonomySession.TermStores,
termStores => termStores.Include
(termStore=>termStore.Name)
);
//Execute the query to the server
clientContext.ExecuteQuery();
// Check if the TaxonomySession is not null
if
(taxonomySession !=
null)
{
// Loop through all the term stores for the taxonomy session
foreach
(TermStore termStore
in
taxonomySession.TermStores)
{
// Print the termstore name
Console.WriteLine(termStore.Name);
}
Console.ReadLine();
}
}
}
}
MMS will be the output.
[Note: Site Collection
http://c4968397007/ is
associated with MMS service application].