How to: Log and Reset InfoPath Forms Services Configuration Settings

For the purposes of this task, the FormsService class and associated members are used to set the default values for most of the items on the Configure InfoPath Forms Services page of the SharePoint 3.0 Central Administration site.

The form contains a button and a rich text box. When executed, the rich text box is populated with the name of the class member used to set a configuration property, and the old and new values of each member.

Note

This topic assumes that Microsoft Visual Studio 2005 is installed on the Web front-end (WFE) or single farm server running InfoPath Forms Services.

Setup The Project

  1. Create a new Visual BasicWindows Application project in Microsoft Visual Studio 2005.

  2. On the Project menu, click Add Reference.

  3. On the .NET tab of the Add Reference dialog box, select Windows® SharePoint® Services, and click OK.

  4. On the Project menu, click Add Reference again.

  5. On the Browse tab of the Add Reference dialog box, browse to the Microsoft.Office.InfoPath.Server.dll assembly, typically located at C:\Program Files\Microsoft Office Servers\12.0\Bin\. Select the assembly and click OK.

Add Controls and Code to the Form

  1. Add the following controls to the form. These can be found in the All Windows Forms category of the Visual Studio Toolbox:

    • A Button control

    • A RichTextBox control

  2. Rename the button to "List and Reset Configuration Settings" by modifying the Text property of the button in the Properties Window.

  3. Reposition and resize the form and the controls until all text can be seen on the button and the RichTextBox control fills most of the form.

  4. On the View menu, click Code.

  5. Paste the code below into the code window, replacing all existing code.

  6. Click Form1.vb [Design] on the Window menu.

  7. In the Properties Window, click the drop-down list box and select Button1.

  8. In the Properties Window, click the Events button, which is typically the fourth button from the left in the row of buttons below the drop-down list box.

  9. In the Action section, click the drop-down for the Click event and select Button1_Click.

  10. On the File menu, click Save All.

  11. Press F5 to run the application.

Example

Use the procedures above to create a new Visual Basic Windows application that uses this code example to log and reset InfoPath Forms Services configuration settings.

Imports Microsoft.SharePoint.Administration
Imports Microsoft.Office.InfoPath.Server.Administration

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim LocalFormsService As FormsService
        Dim LocalFarm As SPFarm = SPFarm.Local
        Dim StrLog As String = ""

        Try
            LocalFormsService = LocalFarm.Services.GetValue(Of FormsService)(FormsService.ServiceName)
            'Build a string with the old a new value of each property
            With LocalFormsService
                StrLog = StrLog + "ActiveSessionsTimeout changed from " + _
                .ActiveSessionsTimeout.ToString() + " to 1440." + Environment.NewLine
                .ActiveSessionsTimeout = 1440

                StrLog = StrLog + "AllowEmbeddedSqlForDataConnections changed from " + _
                .AllowEmbeddedSqlForDataConnections.ToString() + " to False." + Environment.NewLine
                .AllowEmbeddedSqlForDataConnections = False

                StrLog = StrLog + "AllowUdcAuthenticationForDataConnections changed from " + _
                .AllowUdcAuthenticationForDataConnections.ToString() + " to False." + Environment.NewLine
                .AllowUdcAuthenticationForDataConnections = False

                StrLog = StrLog + "AllowUserFormBrowserEnabling changed from " + _
                .AllowUserFormBrowserEnabling.ToString() + " to True." + Environment.NewLine
                .AllowUserFormBrowserEnabling = True

                StrLog = StrLog + "AllowUserFormBrowserRendering changed from " + _
                .AllowUserFormBrowserRendering.ToString() + " to True." + Environment.NewLine
                .AllowUserFormBrowserRendering = True

                StrLog = StrLog + "AllowUserFormCrossDomainDataConnections changed from " + _
                .AllowUserFormCrossDomainDataConnections.ToString() + " to False." + Environment.NewLine
                .AllowUserFormCrossDomainDataConnections = False

                StrLog = StrLog + "AllowViewState changed from " + _
                .AllowViewState.ToString() + " to False." + Environment.NewLine
                .AllowViewState = False

                StrLog = StrLog + "DefaultDataConnectionTimeout changed from " + _
                .DefaultDataConnectionTimeout.ToString() + " to 10000." + Environment.NewLine
                .DefaultDataConnectionTimeout = 10000

                StrLog = StrLog + "MaxDataConnectionResponseSize changed from " + _
                .MaxDataConnectionResponseSize.ToString() + " to 1500." + Environment.NewLine
                .MaxDataConnectionResponseSize = 1500

                StrLog = StrLog + "MaxDataConnectionTimeout changed from " + _
                .MaxDataConnectionTimeout.ToString() + " to 20000." + Environment.NewLine
                .MaxDataConnectionTimeout = 20000

                StrLog = StrLog + "MaxPostbacksPerSession changed from " + _
                .MaxPostbacksPerSession.ToString() + " to 75." + Environment.NewLine
                .MaxPostbacksPerSession = 75

                StrLog = StrLog + "MaxSizeOfFormSessionState changed from " + _
                .MaxSizeOfFormSessionState.ToString() + " to 4194304." + Environment.NewLine
                .MaxSizeOfFormSessionState = 4194304

                StrLog = StrLog + "MaxUserActionsPerPostback changed from " + _
                .MaxUserActionsPerPostback.ToString() + " to 200." + Environment.NewLine
                .MaxUserActionsPerPostback = 200

                StrLog = StrLog + "RequireSslForDataConnections changed from " + _
                .RequireSslForDataConnections.ToString() + " to False." + Environment.NewLine
                .RequireSslForDataConnections = False

                StrLog = StrLog + "ViewStateThreshold changed from " + _
                .ViewStateThreshold.ToString() + " to 40960." + Environment.NewLine
                .ViewStateThreshold = 40960
            End With
            'Populate the rich text box with the log
            RichTextBox1.Text = StrLog
        Catch ex As Exception
            MessageBox.Show("An error has occurred: " + ex.Message.ToString())
        End Try

    End Sub
End Class

See Also

Other Resources

Developing Windows Applications To Perform InfoPath Forms Services Administration Tasks