Adding Crawl Rule




Go back to index

How to add crawl rule


Following code block explains how to programmatically add crawl rule in SSP.

      using System;
      using SPTool.Library;
      
      namespace SPTool.Test
      {
          class Program
          {
              static void Main(string[] args)
              {
                  SPTSharedServiceProvider ssp = new SPTSharedServiceProvider("http://sptool:5000/ssp/admin");

                  // Add Exclusion Crawl Rule
                  SPTReturn returnObj = ssp.AddCrawlRule("http://sptool/","ExclusionRule",false,false, false, "","","");

                  // Add Inclusion Crawl Rule
                  returnObj = ssp.AddCrawlRule("http://sptool/blogs/","InclusionRule", false, false, false, "NTLM", @"Domain\Username", "Password");

                  // Check the status of adding crawl rule
                  if (returnObj.State == SPTState.Success)
                  {
                      // Crawl rule added successfully
                  }
                  else
                  {
                      // Adding crawl rule failed
                  }
              }
          }
      }


Go back to index