共用方式為


Custom Federated Search Web Part Sample

By using Microsoft Search Server 2008 to create federated locations, you can include items from content repositories that are not indexed by the search server's crawler. When you create a federated location, you must also specify its authentication type. The federated results Web Parts included with Search Server 2008 work as expected only for some authentication types. For others, you must create custom versions of the federated search Web Parts.

Overview

This walkthrough provides instructions about how to create and test a custom federated search results Web Part sample that provides a way for the user to enter their credentials, and then passes those credentials in the search request to the federated location. You must create a custom federated search results Web Part when the federated location is configured to use an authentication type that does not work with the federated search Web Parts included with Search Server 2008.

Authentication Types That Work with the Federated Search Web Parts Included with Search Server 2008

The following authentication types work with the federated search Web Parts included with Search Server 2008 without any additional configuration:

  • Anonymous authentication. No credentials are required.

  • All common authentication types, where the credentials specified in the location configuration are automatically passed to the federated location.

  • Per-user Kerberos authentication, where the browsing user's credentials are automatically passed to the federated location.

Per-User Authentication Types That Require Custom Federated Search Web Parts

The following per-user authentication types do not pass the credentials automatically to the federated location:

  • Basic authentication

  • Digest authentication

  • NTLM authentication

  • Forms authentication

  • Cookie authentication

For authentication to work in these scenarios, you must create custom versions of the federated search Web Parts to request the user's credentials, so that the credentials can be passed in the request to the federated location.

For more information, see Creating a Custom Federated Search Web Part with a Credentials UI [Search Server 2008].

The sample Web Part described in this walkthrough works for federated locations that are configured to use the following per-user authentication types:

  • Basic authentication

  • Digest authentication

  • NTLM authentication

You can download the complete code for this sample from the Custom Federated Results Web Part Sample release tab, on the Microsoft Search Server 2008 SDK Samples resource page of the MSDN Code Gallery.

Prerequisites

To use the custom federated search results Web Part sample, your environment must have the following installed:

  • Microsoft Search Server 2008.

  • A test environment for the sample Web Part, with a federated location configured to use Basic, Digest, or NTLM per-user authentication. To set this up, you could use the federated connector from the Federated Search SQL Server Connector Sample [Search Server 2008] as your federated location, and configure the federated connector's Web site to use NTLM, Digest, or Basic authentication.

  • Microsoft Visual Studio 2005 with Microsoft Visual C# or Microsoft Visual Basic enabled.

Completing the Walkthrough

The following topics walk you through creating the custom federated search results Web Part:

Step 1: Set Up the Project for the Custom Web Part [Search Server 2008]

Step 2: Add the Code for the Custom Web Part [Search Server 2008]

Step 3: Deploy the Custom Web Part [Search Server 2008]

See Also

Concepts

Federated Search Overview [Search Server 2008]