Welcome on my SharePoint 2010 blog

Hello,

My name's Roy. I'm a dutch SharePoint & BI consultant/architect at Advantive B.V. At this moment I'm busy with some big SharePoint 2010 projects in The Netherlands. In all the projects I've got different roles, like: Business consultancy, Lead Consultant, Architect (logical and technical), Development and Teaching/courses.

Products where you can ask me about are: SharePoint, Visual Studio, SQL Server, PowerPivot, Analysis and Reporting Services, Visio Services, InfoPath, PerformancePoint Services, Team Foundation Server, Office line.

I love to work and to write about Microsoft SharePoint 2010 so, feel free and read/comment my Blogs!

Greetz.

Wednesday, August 18, 2010

SPMetal & LINQ to SharePoint 2010

Intro
Within SP2010 you have the possibility to reach and use your lists and libraries using Language Integrated Query (LINQ).

LINQ is a feature of the programming languages C# and Microsoft Visual Basic .NET. Compilers are included with Visual Studio.

LINQ adds a SQL-like syntax and vocabulary to each of the languages, which can be used to query data sources. But unlike other languages and query syntaxes which vary from one type of data source to another, LINQ can be used to query, in principle, any data source whatsoever. For this reason, developers may find that it is the only query syntax that they ever need to know.
All that is necessary to make a data source accessible with LINQ is that someone create a LINQ provider for the data source.

A LINQ provider is an implementation of the System.Linq.IQueryable<T> and System.Linq.IQueryProvider interfaces that are included with Microsoft .NET Framework (System.Core.dll). The implementing classes must be public in a managed code assembly. The primary job of the class that implements IQueryProvider is to translate LINQ queries into the language of the data source, such as SQL or XQuery, then call the data source’s application to execute the query.

The provider must also expose a gateway class whose instances can communicate with the data source and output IEnumerable<T> objects. For example, the gateway class for LINQ to SQL is DataContext and the gateway class for LINQ to XML is XDocument. The gateway class must implement System.Linq.IQueryable<T> or have a child property that does so or have a method that returns a type that implements System.Linq.IQueryable<T>. For example, DataContext has a GetTable() method that returns a Table<TEntity> type that implements System.Linq.IQueryable<T>. The latter interface, in turn, has a property of type IQueryProvider. (The gateway class can also directly implement IQueryProvider.) It is objects of type Table<TEntity> that are queried.

In many cases, a LINQ Provider cannot be used by a .NET solution developer unless the developer creates a set of entity classes to represent the subordinate entities in the data source, such as the particular tables of a particular SQL database. Frequently, a lot of such classes must be created (e.g., a database with three dozen tables), so the developer of a LINQ provider will typically include a code generation tool to automate the process of creating these entity classes.

The LINQ to SharePoint Provider is defined in the Microsoft.SharePoint.Linq namespace. It translates LINQ queries into Collaborative Application Markup Language (CAML) queries. It is no longer necessary for developers to know how to write CAML queries. LINQ queries can be used in server code. To query from a client application, use SharePoint’s support for ADO.NET Data Services.

The gateway class for the LINQ to SharePoint provider is Microsoft.SharePoint.Linq.DataContext which represents the data of a SharePoint Foundation Web site. It is parallel in use and function to the System.Data.Linq.DataContext class in the LINQ to SQL provider. Just as the latter class has a GetTable() method that returns a Table<TEntity> object that implements System.Linq.IQueryable<T>, so too, the Microsoft.SharePoint.Linq.DataContext class has a GetList<T> method that returns an EntityList<TEntity> class that implements System.Linq.IQueryable<T>. It is objects of type EntityList<TEntity> that are queried.

How to use
  1. To use LINQ to SharePoint 2010 you have to create a new empty SharePoint visual webpart (example) project in Visual Studio 2010.
  2. Go to cmd-prompt and open the BIN-directory in your 14-hyve.
  3. Enter the following command (launch the spmetal.exe): SPMetal.exe /web:http://yoursite /code:C:\ExampleEntities.cs. The system wil now create a cs-file that you have to include in your project. In this file you can find all your lists and doc libs and fields that you can use in your LINQ queries. Note that the class name is now ExampleEntitiesDataContext. It's based on the name you specify as your code file in the SPMetal.exe command line tool.

    If you were to use /code:C:\Awesome.cs instead, it would generate a class called AwesomeDataContext.
  4. So far so good.... now the cs-file is included in your project, you can use it. Now you have to make an instance of the ExampleEntitiesDataContext class and make an example query:ExampleEntitiesDataContext edc = new ExampleEntitiesDataContext(SPContext.Current.Web.Url); var q = from Example in edc.Documenten where Example.DocumentCreatedBy == "Test" select Example.DocumentCreatedBy;
  5.  You can now use the results in a for each loop, BUT.... sometimes the SPMetal.exe makes some mistakes in his automatic process with custom lists and libraries. When you want to choose a field in your table, you can only see the system fields...

6. The problem: The SPMetal.exe does'nt use the content types that are connected to the list, he takes the default content type for a list: Item and for a Library: Document!!!!

7. Solution: Open your ExampleEntities.cs file and search for your list from which you want to use the fields. In this property change the contenttype to the content type where your fields are in (see the yellow highlighted text):
[Microsoft.SharePoint.Linq.ListAttribute(Name="Documenten")] public Microsoft.SharePoint.Linq.EntityList<Document> Documenten { get { return this.GetList<Document>("Documenten");
}
}
8. Change the text to the content type you need. After that go back to your other cs.file (e.g.: for the webpart) and again open your field property box using intellisense. And....Yes!! There they are: Your fields from the specific content type!! HAVE FUN!! 

Saturday, June 12, 2010

The new, friendlier SP 2010 Content By Query WebPart

This is a nice blog about a very often used and famous webpart: Content by Query WebPart.

The Content By Query webpart (CQWP) is one of the most powerful and most commonly used tools in SharePoint. On top of that it is also highly customizable. A big downside is that customizing the CQWP is tedious work. Especially if you do not want to alter SharePoint native files.

The CQWP simplifies working with Item Styles by introducing slots. A slot is a marker in the Item Style Template which is being filled with the content on runtime. The Content Query Web Part allows you to set the mappings between the slots and the fields using the property pane what allows you to create more semantic and reusable Item Style Templates!

Another great feature of the new Content Query Web Part is the Content to Content concept. Content to Content introduces two tokens that can be used in the Content Query Web Part filters. The PageQueryString token allows you to include in the query a value from a query string parameter and the PageFieldValue token gives you the possibility to filter the query results using a value of another field on the same page. This makes it extremely easy to provide functionality such as related content.

When I was working with the CQWP in SharePoint 2010 I found that most of the known nuisances are still there. For instance the ItemXslLink (and others) are still not configurable in the webpart configuration panel. But it seems one big improvement has been made: You do not longer have to set the CommonViewFields property (well, not if you do it right).
The SharePoint CQWP actively looks in the XSL style sheets for XML attribute references (@) it can’t resolve. If it finds them it will presents the user the possibility in the CQWP toolpart to map these attributes to SharePoint fields. For instance by default SharePoint would map the @Description attribute to the Comments field.

Even nicer is that you can even map multiple fields to one attribute. If the first field is empty the value of the second field is used.  

First of all you start off by creating a new Item Style template just as you would with Office SharePoint Server 2007 – nothing new here. But then the magic happens. As soon as you pick your custom Item Style template in the Web Part properties, CQWP parses the selected template and generates slots for it: every @SomeProperty becomes a slot:

<xsl:template name="Advantive" match="Row[@Style='Advantive']" mode="itemstyle">
    <xsl:variable name="SafeLinkUrl">
      <xsl:call-template name="OuterTemplate.GetSafeLink">
        <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
      </xsl:call-template>
    </xsl:variable>
    <xsl:variable name="DisplayTitle">
      <xsl:call-template name="OuterTemplate.GetTitle">
        <xsl:with-param name="Title" select="''"/>
        <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
        <xsl:with-param name="UseFileName" select="1"/>
      </xsl:call-template>
    </xsl:variable>
    <p>
      <strong>
        <xsl:value-of select="$DisplayTitle"/>
      </strong><br />       <xsl:value-of select="@AdvantiveField1"/>, <xsl:value-of select="@AdvantiveField2"/>
    </p>
    <p>
      <xsl:value-of select="@AdvantiveField3"/>
      <xsl:value-of select="@AdvantiveField4"/>
      <xsl:value-of select="@AdvantiveField5"/>
    </p>
    <p>
      <a href="{$SafeLinkUrl}">Read more</a>
    </p>
  </xsl:template>


Example snippet of itemstyle.xsl the @AdvantiveField1, @AdvantiveField2, @AdvantiveField3 and @AdvantiveField4  attributes are highlighted.

Reload the ItemStyle.xsl sheet in de style library and the result will be presented in the props of the CQWP. You can use the fields (called the props) as the default fields in the CQWP.

Saturday, June 5, 2010

Managed Metadata not supported in Infopath 2010

A very short Blog, but a very usefull:

Managed Metadata is not supported at this moment in Infopath 2010, due some other priorities in the development of Office 2010 (document panel). This is the msdn discussion, in the last section it says the following:

It is a fair chunk of work to get a field supported in InfoPath forms server list upsizing, and this is the first release with the feature.  There are tradeoffs during the development and stabilization of the features.  For the EMM InfoPath feature, we couldn't get the code to the quality bar that we wanted in the time we had, and the rich client (Word/Excel/PPT) customization was deemed higher priority ( as were things like search refinements, multi-lingual support, service federation, enterprise keywords, etc.)


Friday, May 14, 2010

Problem with unactived Managed Metadata features

If you want to use content type publishing on a consuming web application or you want to create metadata columns, the following things are important to keep in mind. Sometimes the UI gives some strange messages that can be solved by adding the features below and set permissions for the users (who need access) on metadata service applications level.

Error with Content type publishing:You can get an error, if you want to publish the content types: "Proxy (association between service app and webapp) cannot be reached". You don't have enough permissions to access the service application.

Error with creating managed metadata column:While creating a metadata column in a library or list you can get the following error: "You need to activate the feature to use the metadata service application". To solve this problem enable the features below.

Another error you can get is: "cannot get terms out of term store". This means you don't have enough permissions on the metadata service applications.


Solution:**First make sure that the users or groups have permissions (view or contribute or full control) to use the metadata service application.**

If you want to use this feature that's part of the metadata service application, you need to activate two features, these features can't be through the UI, so use the powershell script (or stsadm):

enable-spfeature -identity 7201d6a4-a5d3-49a1-8c19-19c4bac6e668 -URL http://<YourWebApp>

enable-spfeature -identity 73ef14b1-13a9-416b-a9b5-ececa2b0604c -URL http://<YourWebApp>

This enables the following features:

MetaDataNav                            7201d6a4-a5d3-49a1-8c19-19c4bac6e668    Web
TaxonomyFieldAdded              73ef14b1-13a9-416b-a9b5-ececa2b0604c      Site

Monday, April 26, 2010

Performance Services 2010: Monitor, Analyse, Plan!

Building Performance Point Dashboards.

Within a few days the new RTM version of SharePoint 2010 (SP2010) will finally be launched! As we already know from the Beta and RC version: SP2010 will bring us a lot of new and cool stuff!

One of these  new things is: Microsoft Performance Point Services 2010 (PPS2010). In the 12 Wave it was a separate product called: Performance Point Server 2007. Within the 14 wave it is integrated in the SP2010 product stack as a separate Service Application.

With PPS2010 you can do your performance management based on underlying datasources. PPS2010 can be split into three parts:

• Monitoring; What is happening and what is happened?
• Analysis; Why has it happened?
• Plan/forecast; What is going to happen/next steps, what do I want to happen?


To answer the above questions you can generate PPS2010 functionalities like:
(Balanced) Scorecards, KPI's, analytical reports (with drilldown) and trend analysis.


Example
Withing this blog we will show you an example of the easyness of creating a
Performance Point dashboard within PPS2010/SP2010.


Prerequisites
• SharePoint 2010 Enterprise
• SQL Server 2008 (x64)
• Contoso Retail DW SQL2008 Example DB (see: codeplex.com or Microsoft.com)
• Business intelligence center template created in SharePoint 2010, from this
   site you can start the Performance Point Dashboard Designer
• A Secure Store Service Application with a master key and application key set.
• A PPS2010 target application ID in Secure Store service application with the
   the credentials set for this target application ID


Steps
1:
From the business intelligence center start the Dashboard Designer. Click on
create dashboards and then click start using performance point services.(see picture below).



2:
Click on the button "Run dashboard designer". The Performance Point service will now download and open the designer application from the SharePoint Server.





3:
The next time you can open the dashboard designer from the Start-menu.



4:
The Dashboard designer start page will look like this:



5:
Make sure that you first created a connection to the Contoso Retail DW in the dashboard designer. This will not be shown in this example.


6:
The next step is to create the scorecard where the KPI's will be integrated. On the create tab click Scorecard. Choose for Microsoft - Analysis Services




7:
Choose the Contoso Retail DW Datasource and click next


8:
Select Create KPI's from SQL Server Analysis Services measures and click Next



9:
Click Add KPI (this will give you the possibility to add an existing KPI from the cube. If you choose for Select KPI you can choose a KPI you created in this workspace. Rename the name of the KPI to: Sample_KPI



10:
In the next screen select a dimension, choose Sales Territory country



11:
Next, choose a measure filter for the target and the actual of the KPI, Choose Greater China as actual and India as target.



12:
In the Add member columns screen, check <Add column members> and choose the date.calender Year field in the dimension textbox. In the member textbox select the years 2008 and 2009


13:
Choose the location in SharePoint (document library) where you want to place your Dashboard content, click Next.


14:
Click Finish and rename the scorecard to: Sample_Scorecard. Your scorecard should look like this:


15:
In the details pane (right) open the dimensions group and pick the field <Category Name> and move it to the right hand side of the <Sample KPI> in the scorecard.



16:
A Screen opens, right click <All Products> and choose Autoselect members --> Select Children. All the underlying categories will dynamically be shown in the scorecard.



17:
Click update in the edit-tab and the scorecard should look like the following:



18:
When you created your first scorecard, we will go further by creating an analytic report, click on the create-tab on analytic chart. You can see that you can also choose an Excel Report or Reporting Services Report.


19:
Choose the Contoso Retail DW Datasource and click finish


20:
Rename the report to: Sample_Pie


21:
Drag the dimensions, measures or named sets you want on to the report designer as shown in the picture below:



22:
Now you can change your report type to: Pie Chart by right clicking on the report



23:
Create another Analytic chart with report type: Line Chart. Choose the dimensions and measures that areshown below:



24:
Call the chart: Sample_Line


24:
On the Create-tab, click KPI details. Rename this one to Sample_KPIDetails.


25:
The last step is to create a dashboard and drag and drop all the items we just created on the dashboard. On the Create-tab click Dashboard and choose 2 zone dashboard. In fact: you're now are going to create a SharePoint site with some webparts in two webpart zones.


26:
Give the page a name, e.g.: Sample_Dashboard. Right click on the dashboard and choose add below. You now will create a zone below, after that click in the new zone and choose: split zone. You now have created a four webpart site.




27:
Now drag and drop your items from the details pane to the dashboard until your screen looks like the following:



28:
Keep your mouse on the scorecard part of the dashboard and drag the Member Unique Name to the Piechart part, you've now created a connection between the both parts.



29:
Drag the Cells context field to the KPI details part of the dashboard, after you've done with this you're dashboard should look like the following:



30:
The most exiting part!! Right click on the dashboard in the workspace browser and choose: Deploy to SharePoint. You're new dashboard will now be uploaded to SharePoint (it creates a new page, with the necessary webparts and publishes all your items to SharePoint). You're Dashboard should look like this:



31:
If you click on Performance Point Content you can see the items you've just created.



Congratulations! You've just had you're first PPS2010 experience!

Thursday, April 8, 2010

Visio Services and SharePoint 2010 - A great link!

With the new product of Visio Services 2010 and it's integration with SharePoint 2010 you now have the possibility to integrate your own Visio diagrams within your own SharePoint 2010 environment. But that's not all, you can also make dynamic Visio diagrams by connecting the Visio Shapes to external datasources.
This blog shows an example of how to create a Visio diagram with external data and publish it to SharePoint 2010.

Prerequisites:
- Visio Services 2010
- SharePoint 2010
- An external datasource
- Target application ID created in Secure Store Service App
- Target application ID connected to Visio Service App


1:
Open Visio and create your own Visio diagram, I created a diagram which shows revenue per country per employee. You can also make a diagram which visualizes your network infrastructure or shows a specific process (flowchart) of your company.



2:
Save the Visio diagram as a "Web drawing"




3:
New in Visio 2010 (Professional and Premium versions) is the Data-tab, click on this tab and observe the new possibilities!




4:
Click on Link data to shapes, choose your datasource (I've chosen SQL Server) and select the data/columns you want to use in your diagram (the data you want to link to your Visio Shapes).


5:
When you successfully created a connection you see the External Data Window below your Visio diagram with your chosen resultset.


6:
If you're dataset is correct, click in the datatab on Data Graphics and create an new data graphic.




7:
Click in the top left on new item (image below) and now you can add some treshholds and checks. These items will be connected to your data graphics item you just created. See examples below:






Example 1

Example 2

Example 3

8:
Now it's time to connect the data to the Visio shapes, there are two ways to do this:

- Select a shape in the Shape selector en pick a specific row in de external data window and drag this row to the diagram.

- Drag a shap to the diagram en connect a row to the shape afterwards
After you connected your rows your diagram could look like this:



9:
On your right hand side you can see the Shape data window (see picture above)


10:
Now we're ready to save (share) it to SharePoint, click on file and the backstage appears, choose share and choose a Sharepoint library where you want to store the Visio Web Drawing.





11:
Open a SharePoint site and edit the page, choose to insert a new webpart and choose Office client applications, and Visio Web Access. Click add to add the webpart to your site.



12:
In the tool pane of the webpart, select your new Visio diagram, change some settings if you think it's necessary. Click apply and ok in the webpart-properties. Check-in your page and your SharePoint site with Visio could look like this:





13:
Visio ask you if you want to refresh the underlying data when the diagram refreshes. Click on "Refresh always" if you want to do that.

Congratulations: Your first Visio integration with SP2010 is a fact!

Saturday, April 3, 2010

Publish a Managed Metadata Service cross-farm

Most important part (different than Technet document) is marked in Purple!
[Please keep in mind that this applies to a pre-release version of SharePoint Server 2010, and may change before the product is released]

Some of the service applications in SharePoint Server 2010 support sharing across SharePoint farms, as described in this article from TechNet. This post describes how to do it with a Managed Metadata Service.

To be able to subscribe to content types and terms from a Managed Metadata Service in another farm, there are a few things you need to do. Although this could seem like a somewhat cumbersome procedure for accomplishing something rather simple, it’s necessary for having control of your systems, and keeping them protected from intruders. Besides, you only have to do it once, and it really shouldn’t take you more than 10 minutes when you know what to do, which is exactly what I’m about to explain to you.

Most of the operations can be performed using SharePoint 2010 Central Administration, but I encourage you to use PowerShell instead, as this is a lot faster once you get used to it. There are six steps you need to follow, and I recommend doing them in the following order:
  1. Set up a trust relationship between the farms
  2. Set up Application Discovery and Load Balancer Service Application permissions
  3. Publish Managed Metadata Service
  4. Connect proxy to Managed Metadata Service
  5. Add proxy to service connection group
  6. Set up Managed Metadata Service permissions
In this post, the publisher farm is the farm in which the Managed Metadata Service is running, while the consumer farm is the farm which will consume data from the publishing farm.
Before we begin, let me first briefly describe the environment we’ll be working with:
  • The publisher farm is called “Enterprise Services Farm”, and has a Managed Metadata Service application called “Enterprise Metadata Service”. This service application consists of a term store, and a content type syndication hub.
  • The consumer farm is simply called “Collaboration Farm”.
Although documentation for most of the necessary operations can be found on TechNet, I’m including the actual PowerShell commands to give you an example of how it’s done. Please note that commands with brackets like this <content> requires you to replace the brackets and content with what the content describes.
Ok, let’s get started!

Set up a trust relationship between the farms

For the server farms to be able to communicate, you need to set up a trust relationship between them. This enables the farms to know that a service request is actually coming from the farm it claims to be coming from, and also enables federated authentication of users potentially not present in both farms. Farm root certificates must be exchanged between the servers, and a STS certificate must be exported from the consumer and imported to the publisher. How to set up the trust relationship is described in detail on TechNet.
On the publisher farm, run the following commands to export the farm root certificate to c:\temp on the server:
$rootCert = (Get-SPCertificateAuthority).RootCertificate
$rootCert.Export("Cert") | Set-Content C:\temp\EnterpriseServicesRootCert.cer -Encoding byte
Run the following to export the necessary certificates on the consumer farm to c:\temp on the server:
$rootCert = (Get-SPCertificateAuthority).RootCertificate
$rootCert.Export("Cert") | Set-Content "C:\temp\CollaborationRootCert.cer" -Encoding byte

$stsCert = (Get-SPSecurityTokenServiceConfig).LocalLoginProvider.SigningCertificate
$stsCert.Export("Cert") | Set-Content "C:\temp\CollaborationSTSCert.cer" -Encoding byte
Copy the files from the c:\temp folder on the publisher farm to the c:\temp folder on the consumer farm and vice versa.
Run the following commands on the publisher farm to set up the trust relationship with the consumer farm:
$trustCert = Get-PfxCertificate "C:\temp\CollaborationRootCert.cer"
New-SPTrustedRootAuthority Collaboration -Certificate $trustCert

$stsCert = Get-PfxCertificate "c:\temp\CollaborationSTSCert.cer"
New-SPTrustedServiceTokenIssuer Collaboration -Certificate $stsCert
Finally, run these commands on the consumer farm to set up the trust relationship with the publisher farm:
$trustCert = Get-PfxCertificate "C:\temp\EnterpriseServicesRootCert.cer"
New-SPTrustedRootAuthority EnterpriseServices -Certificate $trustCert

Set up Application Discovery and Load Balancer Service Application permissions

The Application Discovery and Load Balancer Service Application, aka Topology Service, handles discovery of the farm’s service applications, providing other farms with the information necessary for them to be able to consume any of the farm’s published service applications (it also serves purposes inside the farm, but that’s not the subject of this post). The only supported rights for this service application is “Full Control”, which is what we’ll grant.
On the consumer farm, run the following command to get the id of the consumer farm:
(Get-SPFarm).Id
Copy the Id output from this command, and run the following command on the publisher farm:
$security = Get-SPTopologyServiceApplication | Get-SPServiceApplicationSecurity
$claimProvider = (Get-SPClaimProvider System).ClaimProvider
$principal = New-SPClaimsPrincipal -ClaimType "http://schemas.microsoft.com/sharepoint/2009/08/claims/farmid" -ClaimProvider $claimProvider -ClaimValue <farmid from previous command>
Grant-SPObjectSecurity -Identity $security -Principal $principal -Rights "Full Control"
Get-SPTopologyServiceApplication | Set-SPServiceApplicationSecurity -ObjectSecurity $security 

Publish Managed Metadata Service

To enable content types and terms to be accessible from outside the farm, the Managed Metadata Service must be published for outside consumption. How to publish the service application is described in detail in this article.
On the publisher farm, run the following command to publish the Managed Metadata Service called “Enterprise Metadata Service”:
Publish-SPServiceApplication (Get-SPMetadataServiceApplication “Enterprise Metadata Service”)

Connect proxy to Managed Metadata Service

Next, we need to create a proxy for the “Enterprise Metadata Service” in the consumer farm. On the publisher farm, run the following command to get the URI of the “Application Discovery and Load Balancer Service Application” (which will provide the consumer farm with information about the “Enterprise Metadata Service”):
Get-SPTopologyServiceApplication
Copy the LoadBalancerUrl from the output of the previous command to the consumer farm, and then run the following command to get the URI of the Enterprise Metadata Service application, and create a local proxy for it:
New-SPMetadataServiceApplicationProxy -Name “Enterprise Metadata Service Proxy” –URI (Receive-SPServiceApplicationConnectionInfo -FarmUrl <LoadBalancerUrl from the previous command> | Where {$_.Name -eq "Enterprise Metadata Service"}).Uri

Add proxy to service connection group

Run the following command on the consumer farm to add the new proxy to the default proxy group:
Add-SPServiceApplicationProxyGroupMember (Get-SPServiceApplicationProxyGroup -default) -Member (Get-SPMetadataServiceApplicationProxy "Enterprise Metadata Service Proxy")
The result of this is that all web applications using the default proxy group will use the “Enterprise Metadata Service Proxy” too.

Set up Managed Metadata Service permissions

Finally, to allow the consumer farm to connect to the Managed Metadata Service on the publisher farm, you have to grant the consumer farm permissions to the service application. The Managed Metadata Service supports three permissions: ”Read Access to Term Store”, “Read and Restricted Write Access to Term Store” and “Full Access to Term Store”. In this example, we’ll grant the consumer farm the least permissions, “Read Access to Term Store”:
On the consumer farm, run the following command to get the id of the farm:
(Get-SPFarm).Id
Copy the outcome to the publisher farm, and then run the following commands there:
$security = Get-SPMetadataServiceApplication "Enterprise Managed Metadata Service" | Get-SPServiceApplicationSecurity
$claimProvider = (Get-SPClaimProvider System).ClaimProvider
$principal = New-SPClaimsPrincipal -ClaimType "http://schemas.microsoft.com/sharepoint/2009/08/claims/farmid" -ClaimProvider $claimProvider -ClaimValue <farmid from previous command>
Grant-SPObjectSecurity -Identity $security -Principal $principal -Rights "Read Access to Term Store"
Get-SPMetadataServiceApplication "Enterprise Metadata Service" | Set-SPServiceApplicationSecurity -ObjectSecurity $security

That’s it, you’re up and running with a Managed Metadata Service that is shared between the two server farms!
The only thing left to do is to decide what you want to consume through the proxy, and configure it accordingly. You can learn more about this on TechNet.
Finally, I’d like to share some error messages I’ve received related to the tasks described here, and what was their resolution in my case, to ease your troubleshooting:
  • If you try to manage your Managed Metadata Service Proxy on the consumer farm from the SharePoint 2010 Central Administration and get the error message “The Service Application being requested does not have a Connection associated with the Central Administration web application. To access the term management tool use Site Settings from a site configured with the appropriate Connection”, this could be because your proxy has not been added to a proxy group. See Add proxy service to connection group.
  • Managed Metadata Service Proxy on the consumer farm from the SharePoint 2010 Central Administration and get the error message “The Managed Metadata Service or Connection is currently not available. The Application Pool or Managed Metadata Web Service may not have been started. Please Contact your Administrator”, this could be because your farm doesn’t have the right permissions to the Managed Metadata Service. See Set up Managed Metadata Service permissions.