ExemptUserAgentCollection Class

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

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

public sealed class ExemptUserAgentCollection : SPPersistedChildCollection<ExemptUserAgent>

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.


The Windows SharePoint Services 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.

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.


Browse for the [Microsoft.Office.InfoPath.Server] assembly at <drive>:\Program Files\Microsoft Office Servers\12.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.

Visual Basic

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

        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.Write("Press Enter to Continue")
    Catch ex As Exception
        Console.WriteLine("Error: " + ex.Message)
        Console.Write("Press Enter to Continue")
    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;

        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.Write("Press Enter to Continue");
    catch (Exception ex)
        Console.WriteLine("Error: " + ex.Message);
        Console.Write("Press Enter to Continue");

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

Community Additions