Previous in Contents Next in Contents

Creating and Accessing ISiteRestriction Interface Objects

You create an ISiteRestriction interface object by calling the ISiteRestrictions.Add method. You access an ISiteRestriction interface object by calling the Item property. Because ISiteRestrictions is a collection, you can access all ISiteRestriction interface objects using a for each loop, as in the following example, where objSite is the name you give to the ISiteRestriction interface object:

Option Explicit 
On Error Resume Next 

const AUTH_TYPE_ANONYMOUS = 0
const AUTH_TYPE_NTLM      = 1
const AUTH_TYPE_BASIC     = 2

Dim objSearchAdmin, objBuildCatalog, objSite, Message 

Set objSearchAdmin = CreateObject("Search.SearchAdmin.1") 
Set objBuildCatalog  = _
  objSearchAdmin.BuildServer.BuildCatalogs("KMSampleCatalog2")

'Avoid Microsoft.com
objBuildCatalog.Sites.Add "Microsoft.com", False

'Add site MySite.com and set the account properties 
Set objSite = objBuildCatalog.Sites.Add("MySite.com", True) 

objSite.SetAccount "AdminTest", "HelpMeMrWizard", AUTH_TYPE_NTLM

For Each objSite in objBuildCatalog.Sites
  If objSite.Included Then 
    Message = "Search crawls the site " & objSite.Name 

    If NOT objSite.AccountName = "" Then 
      Message = Message & " under the account name " _
        & objSite.AccountName 
    End If 

    Select Case objSite.AuthenticationType 
      Case AUTH_TYPE_ANONYMOUS
        Message = Message & " and uses anonymous login."
      Case AUTH_TYPE_NTLM
        Message = Message & " and uses Windows NT challenge-and-response login."
      Case AUTH_TYPE_BASIC
        Message = Message & " and uses basic (clear text) login."
    End Select

    'See Accessing ISitePath Interface Objects

    'for additional code that displays the path restrictions.

    Wscript.Echo Message 
  Else
    Wscript.Echo "Search avoids " & objSite.Name 
  End If
Next

'Release objects 
Set objSite         = Nothing 
Set objBuildCatalog = Nothing 
Set objSearchAdmin  = Nothing 
 

© 1997-2000 Microsoft Corporation. All rights reserved.