ExemptUserAgentCollection Class

A collection of user agents that can receive InfoPath files from InfoPath Forms Services instead of Web pages.

Inheritance Hierarchy

System.Object
  Microsoft.SharePoint.Administration.SPPersistedObjectCollection<ExemptUserAgent>
    Microsoft.SharePoint.Administration.SPPersistedChildCollection<ExemptUserAgent>
      Microsoft.Office.InfoPath.Server.Administration.ExemptUserAgentCollection

Namespace:  Microsoft.Office.InfoPath.Server.Administration
Assembly:  Microsoft.Office.InfoPath.Server (in Microsoft.Office.InfoPath.Server.dll)

Syntax

'Declaration
<GuidAttribute("ad1e686e-bc12-42a6-a5be-1eac32eed98b")> _
Public NotInheritable Class ExemptUserAgentCollection _
    Inherits SPPersistedChildCollection(Of ExemptUserAgent) _
    Implements IBackupRestoreConfiguration, IBackupRestore
'Usage
Dim instance As ExemptUserAgentCollection
[GuidAttribute("ad1e686e-bc12-42a6-a5be-1eac32eed98b")]
public sealed class ExemptUserAgentCollection : SPPersistedChildCollection<ExemptUserAgent>, 
    IBackupRestoreConfiguration, IBackupRestore

Remarks

This collection represents search bots that can index or other agents that can access InfoPath files stored on a site. The default ExemptUserAgentCollection includes:

  • crawler

  • googlebot

  • ms search

  • msnbot

  • msoffice

  • slurp

These user agents represent search bots that are commonly used in an enterprise environment. If a different search technology is being used and InfoPath files are not being indexed, the user agent for that technology should be added to the collection using the Add method of this collection. The InfoPath client is not present in the collection because the client detection logic does not solely rely on the user agent information detected in the HTTP request.

For more information about user agents, search for the term "user agent" on the Internet.

Note

The SharePoint Foundation command line utility, stsadm.exe, can also be used to add or remove user agents from the collection. The command line syntax is stsadm –o addexemptuseragent –name and stsadm –o removeexemptuseragent –name, where name is the user agent name.

Examples

The following example writes the number of ExemptUserAgent objects and lists them from the collection. References are required in the Visual Studio project to the Microsoft.Office.Server, Microsoft.Office.InfoPath.Server, and Microsoft.SharePoint assemblies.

Note

Browse for the Microsoft.Office.InfoPath.Server assembly at <drive>:\Program Files\Microsoft Office Servers\14.0\Bin. The Microsoft.Office.Server reference is listed as Microsoft Office Server component and the Microsoft.SharePoint reference is listed as Windows SharePoint Services on the .NET tab of the Add Reference dialog box.

The following import statements are required for the

Microsoft.Office.Server, Microsoft.Office.InfoPath.Server.Administration, and Microsoft.SharePoint.Administration namespaces:

    Dim LocalFormsService As FormsService
    Dim LocalFarm As SPFarm
    Dim ExUserAgents As Integer
    Dim ExUserAgent As ExemptUserAgent
    Dim ExUserAgentsCollection As ExemptUserAgentCollection

    Try
        LocalFarm = SPFarm.Local
        LocalFormsService = LocalFarm.Services.GetValue(Of FormsService)(FormsService.ServiceName)
        ExUserAgents = LocalFormsService.ExemptUserAgents.Count()
        Console.WriteLine("Number of exempt user agents: " & ExUserAgents.ToString())
        ExUserAgentsCollection = LocalFormsService.ExemptUserAgents
        For Each ExUserAgent In ExUserAgentsCollection
            Console.WriteLine(ExUserAgent.Name)
        Next
        Console.Write("Press Enter to Continue")
        Console.ReadLine()
    Catch ex As Exception
        Console.WriteLine("Error: " + ex.Message)
        Console.Write("Press Enter to Continue")
        Console.ReadLine()
    End Try

The following using statements are required for the Microsoft.Office.Server, Microsoft.Office.InfoPath.Server.Administration, and Microsoft.SharePoint.Administration namespaces.

    FormsService localFormsService;
    SPFarm localFarm = SPFarm.Local;
    Int16 exAgents;
    ExemptUserAgentCollection exUserAgentCollection;

    try
    {
        localFormsService = localFarm.Services.GetValue<FormsService>(FormsService.ServiceName);
        exAgents = (Int16)localFormsService.ExemptUserAgents.Count;
        Console.WriteLine("Number of exempt user agents: " + exAgents.ToString());
        exUserAgentCollection = localFormsService.ExemptUserAgents;
        foreach(ExemptUserAgent exUserAgent in exUserAgentCollection)
        {
            Console.WriteLine(exUserAgent.Name);
        }
        Console.Write("Press Enter to Continue");
        Console.ReadLine();
    }
    catch (Exception ex)
    {
        Console.WriteLine("Error: " + ex.Message);
        Console.Write("Press Enter to Continue");
        Console.ReadLine();
    }

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

ExemptUserAgentCollection Members

Microsoft.Office.InfoPath.Server.Administration Namespace