Thursday, August 19, 2010

Sharepoint 2010 Publishing and Consuming Cross-Farm Services

In my previous post I discussed about how to set trust relationship between Sharepoint farms and in relation with that article I will discuss on this article about how to publish and consume cross-farm services. Cross-farm services in Sharepoint 2010 is the ability to publish and consume services that is running from different Sharepoint farms for example you can publish a search service or profile service and let other Sharepoint farm to subscribe to this service.

Setup Publishing Search Service

  • Log on to Central Administration and under Application Management click Manage services application.
  • On Service Applications page click on Search Service Application then click on Publish button located on the top of the page.

    image
  • Input the necessary information from the popup window when Publish button was clicked. Copy Published URL and save it somewhere else this will be useful when configuring consumer farm. Click OK button to continue. You need to set the trust relationship with another farm follow steps on my previous post.

    image
  • Add Search permission, by searching the consuming farm id. To get the consuming farm id log in to consuming farm and open Sharepoint 2010 Management Shell from Start > All Programs > Microsoft Sharepoint 2010 Products. Execute Get-SPFarm | Select Id as shown below.

    image
  • Add the consuming farm id to have full control access permission. Click OK to continue.

    image

Setup Consuming Farm

  • Log on to Consuming Farm, go to Central Administration > Application Management > Manage services applications
  • Click Connect > Search Service Proxy and type the Publishing URL and click OK and wait while it connects to proxy service.

    image
  • Click Search Service Application and click OK. Enter the Connection Name of the service and click OK. Wait while it finalize the connection and click OK once its done.
    image
  • Set the new search service proxy as a default search to a web application to do this go to Central AdministrationApplication Management > Web Applications and select the appropriate web application and click Service Connections on the ribbon. Click OK when done.

    image
  • Create Enterprise Search and then try to search something that should exists in the other farm and If everything was configured as expected you should get a search result.

Additional reading http://www.kowalski.ms/2010/07/16/sharepoint-server-2010-enterprise-service-application-publishing-and-consuming-farms/.

Monday, August 9, 2010

Configuring Sharepoint 2010 Trust Relationship with other Farm

In Sharepoint 2010 you can share service in different Farm they called it Cross-Farm Service application.

Sharing services is no longer exclusive to SharePoint Server, and services are no longer contained in Shared Services Providers (SSPs). In more details refer to this article http://technet.microsoft.com/en-us/library/cc560988.aspx.

You need to set the trust between farm before cross-farm service is enabled http://technet.microsoft.com/en-us/library/ee704552.aspx.

Exporting and copying certificates
An administrator of the consuming farm must provide two trust certificates to the publishing farm: a root certificate and a security token service (STS) certificate. An administrator of the publishing farm must provide a root certificate to the consuming farm.

You can only export and copy certificates by using Windows PowerShell 2.0.

To export the root certificate from the consuming farm
On the Start menu, click Administrative Tools.

  1. Click SharePoint 2010 Management Shell.
  2. At the Windows PowerShell command prompt, type each of the following commands:
  3. Copy Code

$rootCert = (Get-SPCertificateAuthority).RootCertificate

$rootCert.Export("Cert") | Set-Content <C:\ConsumingFarmRoot.cer> -Encoding byte

Where <C:\ConsumingFarmRoot.cer> is the path of the root certificate.

To export the STS certificate from the consuming farm
At the Windows PowerShell command prompt, type the following commands:

  1. Copy Code

$stsCert = (Get-SPSecurityTokenServiceConfig).LocalLoginProvider.SigningCertificate

$stsCert.Export("Cert") | Set-Content <C:\ConsumingFarmSTS.cer> -Encoding byte

Where <C:\ConsumingFarmSTS.cer> is the path of the STS certificate.

To export the root certificate from the publishing farm

  1. On the Start menu, click Administrative Tools.
  2. Click SharePoint 2010 Management Shell.
  3. At the Windows PowerShell command prompt, type the following commands:
  4. Copy Code

$rootCert = (Get-SPCertificateAuthority).RootCertificate

$rootCert.Export("Cert") | Set-Content <C:\PublishingFarmRoot.cer> -Encoding byte

Where <C:\PublishingFarmRoot.cer> is the path of the root certificate.

To copy the certificates

  1. Copy the root certificate and the STS certificate from the server in the consuming farm to the server in the publishing farm.
  2. Copy the root certificate from the server in the publishing farm to a server in the consuming farm.

Managing trust certificates by using Central Administration
You can manage trusts on a farm only after the relevant certificates have already been exported and copied to the farm.

To establish trust by using Central Administration

  1. Verify that the user account that is performing this procedure is a member of the Farm Administrators SharePoint group.
  2. On the SharePoint Central Administration Web site, click Security.
  3. On the Security page, in the General Security section, click Manage trust.
  4. On the Trust Relationship page, on the ribbon, click New.
  5. On the Establish Trust Relationship page:
    • Supply a name that describes the purpose of the trust relationship.
    • Browse to and select the Root Authority Certificate for the trust relationship. This must be the Root Authority Certificate that was exported from the other farm by using Windows PowerShell, as described in Exporting and copying certificates.
    • If you are performing this task on the publishing farm, select the check box for Provide Trust Relationship. Type in a descriptive name for the token issuer and browse to and select the STS certificate that was copied from the consuming farm, as described in Exporting and copying certificates.
    • Click OK.

After a trust relationship is established, you can modify the Token Issuer description or the certificates that are used by clicking the trust, and then clicking Edit. You can delete a trust by clicking it, and then clicking Delete.

Friday, July 23, 2010

Content Type Syndication with Sharepoint 2010

A new feature of Sharepoint 2010 is the ability to publish content types to all web application and site collections from a centralized Content Type Hub.

For more details about Content Type Syndication and with code example you can visit this url http://msdn.microsoft.com/en-us/library/ff394469.aspx.

To activate Content Type Syndication on Sharepoint 2010 follow the instructions below:

Go to Central Administration and under Application Management click on Manage service applications.image

On Service Applications page locate and select Managed Metadata Service then click Properties button from the ribbon toolbar.image

On property window enter the URL for the site collection (Content Type hub) from which this service application will consume content types then click Ok button to complete.

 image

Select Managed Metadata Service on Service Applications and click on properties from ribbon toolbar.

image 

Check “Consumes content types from the content type Gallery at …” from the Managed Metadata Service Connection property.

image

Now you can login to Content type hub which you defined from the above instruction.

Go to Site Settings > Galleries > Site Content Types click on one of the content types listed and notice that there will be a new link Manage publishing for this content type, click it.

image

Now you have the ability to publish content types to all Web Applications and Site Collections cool!

image

Monday, April 19, 2010

Hardware and sotware requirements for Sharepoint 2010

You can find all the necessary requirements for installing Sharepoint 2010 in this link http://technet.microsoft.com/en-us/library/cc262485(office.14).aspx

Tuesday, January 26, 2010

Web Part Page Maintenance and some url tricks

Sometime during development a web part might encounter unhandled exceptions and that will cause your page to have the red colored error text to appear.

In some cases you want to remove this problimatic web part, to do this simply append "?contents=1" to the url. The web part maintenance will appear and you can remove the web part with error.

Some other url tricks to manage sharepoint page view:

?PageView=Shared&ToolPaneView=2 --> Change everyone's view of a particular page.
?PageView=Personal&ToolPaneView=2 --> change private view of a particular page.

cheers :).

Monday, January 4, 2010

Thread Creation with ManualResetEvent

Use ManualResetEvent to synchronize the multiple threads that are running. In this example the main thread will wait for all the threads to complete before exiting the caller method by using ManualResetEvent.WaitAll.

In the code below, I created a pattern with thread creation. Remeber that creating a thread is quite expensive, so remember tha you shoul create a thread only when you know how many process you will be running simutaneously and it may take time to process meaning it may run for 10 seconds or more.

If you have more than 20 threads to be created then try to execute them in batch specially if these threads will take time to process. Let 20 threads to finish first before creating another new batch of threads. This pattern was demostrated in the code below, with some code comments.

But if you have multiple processes that may take only for a few seconds then maybe consider using ThreadPool, which I will be discussing in my next blog.

Code:



Output:



Note:

You will encounter an error when using ManualResetEvent.WaitAll with a single threaded method meaning when a method has a declared [STAThread]

See a good pattern on how to use ManualResetEvent with a Single Threaded Method.

Threading with anonymous method

One of the enhancements to C# in version 2.0 is anonymous methods. These allow you to specify blocks of code as methods within other methods, and use those methods as delegates. You can access variables (including local variables and parameters of the "outside" method) within the anonymous method.

So with this enhancement it is now very easy to pass delegated method in a created thread.

Before you need to pass an object and cast it inside the delegated function.

for example, if you need to pass multiple strings to a delegated function, then you need to use delimeter and then parse it in delegated function, as shown in the example below.



Now with the enhancement with .Net 2.0, it easier.

Using with ThreadPool

ThreadPool.QueueUserWorkItem(delegate { d.Worker2("my string parameter"); });

or with lambda exporession

ThreadPool.QueueUserWorkItem(e => d.Worker2("my string parameter"));

Using with ParameterizedThreadStart

Thread t = new Thread(new ParameterizedThreadStart(delegate{ d.Worker("my string parameter");}));

Code Example: