Go back to index
How to add scope rule to scopes in Site Collection
Following code block explains how to programmatically add scope rule to scopes in Site Collection.
using System;
using SPTool.Library;
using System.Collections;
namespace SPTool.Test
{
class Program
{
static void Main(string[] args)
{
SPTSite site = new SPTSite("http://sptool/");
// Add web address scope rule
SPTReturn returnObj = site.AddWebAddressScopeRule("SPTool Site Scope", "Folder", "http://sptool/test/", "Include");
// Add property query scope rule
//returnObj = site.AddPropertyQueryScopeRule("SPTool Site Scope", "Author", @"Domain\UserName", "Include");
// Add all content scope rule
//returnObj = site.AddAllContentScopeRule("SPTool Site Scope");
// Check the status of scope rule addition
if (returnObj.State == SPTState.Success)
{
// Adding scope rule successful
}
else
{
// Adding scope rule failed
}
}
}
}
Go back to index