Working with the Sample

Reading the Sample

The following table shows the sections of the code sample, the purpose of each section, the interface implemented, a description of methods and functionality implemented, and the file where the source code can be found.

Purpose Interface Description Source file
DLL entry point for the protocol handler None
  • Implements the following DLL exports:
    • DllMain
    • DllCanUnloadNow
    • DllGetClassObject
    • DllRegisterServer
    • DllUnregisterServer
simpleph.cpp
The protocol handler ISearchProtocol Class CSimpleProtocolHandler implements the following methods: SearchProtocol.cpp
The accessor for an individual URL item IUrlAccessor Class CUrlAccessor implements the following interface methods:

Additional non-interface methods:

  • CUrlAccessor::Init – internal initialization for the UrlAccessor object
UrlAccessor.cpp
Create directory filter to enumerate items in the file share IFilter Class CDirFilter implements the following interface methods:
  • Init
  • GetChunk
  • GetText

Additional private method:

  • CDirFilter::Init
dirfilter.cpp
Initialize data for a URL item None Populates data structures with item information and validates path derived from the URL of them item utilities.cpp

The CUrlAccessor::Init method****initializes the accessor and determines the last modified time for the URL item. It is called by CSearchProtocol::CreateAccessor and receives the URL for the current item, and pointers to the AUTHENTICATION_INFO, INCREMENTAL_ACCESS_INFO, and ITEM_INFO data structures.

The private CDirFilter::Init method initializes the directory filter and initiates the enumeration process. The CDirFilter::GetChunk method generates information, such as Globally Unique Identifiers (GUIDs), for the enumerated items in the content source. The CDirFilter::GetText method generates a path to the enumerated items.

Building the Sample

To build the sample:

  1. Open a command window.
  2. Set environment variables.
  3. Switch to the directory where the sources for the sample are located. For example type, "cd C:\<MyDirectory>".
  4. At the command prompt, type "nmake all".

If you built the sample successfully, a file called simpleph.dll is created in your working directory.

Running the Sample

To run the sample:

  1. Open a command window.

  2. Register the protocol handler, type "regsvr32 simpleph.dll".

  3. You may need to configure your default content access account to give the Gatherer access to the file share you will be crawling.

    Note

    For more information about configuring the default content access account, see the "Specify Access Accounts" and "Configure the Default Content Access Account" sections in the "Managing Servers" chapter in SharePoint Portal Server Administrator's Guide.

  4. Restart the Search Service so that the newly registered protocol handler is recognized.

    Note

    For more information about stopping a SharePoint Portal Server service, see the "Stop and Start the SharePoint Portal Server Computer" section in the "Managing Servers" chapter in SharePoint Portal Server Administrator's Guide.

  5. To make the files accessible to the browser, you should share out the path to the content source the protocol handler is accessing. For example, if the file share you want to crawl is "C:\temp" directory, you should share "C:\temp" as "\\MyServer\temp".

  6. Create an access location mapping that replaces "simple:///C:\temp" with "\\MyServer\temp".

    Note

    For more information modifying access location mappings, see the "Making Content Available for Searching", "Modify Index Settings", and "Configure Access Location Mapping Rules" sections in the "Managing the Workspace" chapter in SharePoint Portal Server User's Help.

    Note

    The sample protocol handler accesses a file share, so the host name for the content source is omitted from the content source URL.

  7. Add a new content source.

    Note

    For information about adding a content source, see the "Add a Content Source" section in the "Add and Manage Content Sources" chapter in SharePoint Portal Server User's Help. Type "simple:///C:\temp".

If you select the check box indicating that the crawl should begin immediately, the status of the crawl will be displayed. There will be a notification when the crawl is done. To view the Gatherer log, select click here for detailed log. This log contains URL specific information that is logged for each item as the Gatherer processes it. Unless you enable this feature in the Gatherer settings, the Gatherer does not log items that are processed successfully.

Once you have installed the protocol handler, the "simpleph.dll" is locked by the Search Service and the file cannot be moved, deleted or overwritten. To move, delete or overwrite "simpleph.dll", you must first uninstall the sample protocol handler.

To uninstall the sample:

  1. Stop the Search Service.

    Note

    For more information about stopping a SharePoint Portal Server service, see the "Stop and Start the SharePoint Portal Server Computer" section in the "Managing Servers" chapter in SharePoint Portal Server Administrator's Guide.

  2. To unregister the protocol handler, type "regsvr32 /u simpleph.dll".

  3. Delete the "simpleph.dll" file.

  4. Restart the Search Service.

Verifying the Sample

At any point during a crawl you can use the Event Viewer to see if any system errors were logged during the crawl. In Event Viewer, select Application Logs and look for entries for "Microsoft Search."

When the crawl has completed, perform a query through the dashboard site for an item that can only be found on the file share crawled by the sample protocol handler.