We have a customer that is creating a .NET application and using the SDK and Windows AD user authentication with impersonation. The code they are running is below. When we run our browser and IIS on the same server, the application and interface to Laserfiche works. We seem to be having issues authenticating from IIS to Laserfiche impersonating with the AD credentials from client’s browser. And here’s the error from our first TRY Statement:
Error System.InvalidOperationException: Operation is not in progress. at Laserfiche.RepositoryAccess.Search.GetSummaryStats(Flags flags) at Laserfiche.RepositoryAccess.Search.GetSummaryStats() at Vxxxxxx.VxxxxxxDocs.grdvVDocuments_PreRender(Object sender, EventArgs e)
Try
            Dim current = System.Security.Principal.WindowsIdentity.GetCurrent()
            Dim clientID As WindowsIdentity = DirectCast(HttpContext.Current.User.Identity, WindowsIdentity)
            Using wic = clientID.Impersonate()
                ' Log into Repository
                Dim myRepoReg As New RepositoryRegistration(lfinfo(0), lfinfo(1))
                Dim mySess As New Session()
               Try
                    mySess.LogIn(myRepoReg)
                Catch er As Exception
                    lblVetName.Text = "Login Error " + er.ToString
                    WebMsgBox.Show("Error " + er.ToString)
                End Try
                'Search for Vxxxxx Folder
                Dim mySearch As Search = New Search(mySess)
                mySearch.Command = "{LF:Name=""" & VetID & """, Type=""F""} & {LF:LOOKIN=""" & ConfigurationManager.AppSettings("LaserficheCaseFolder") & """, SUBFOLDERS=0}"
                Try
                    mySearch.Run()
                Catch er As Exception
                    lblVetName.Text = " Search Error " + er.ToString
                    WebMsgBox.Show("Error " + er.ToString)
                End Try
                'If Case Folder does not exist, create it
                Dim searchStatistics As SearchStatistics = mySearch.GetSummaryStats()
                If searchStatistics.FolderCount = 0 Then
                    Dim parentFolder As FolderInfo = Folder.GetFolderInfo("\\Vxxxxx Application\\Case Documents", mySess)
                    Dim newFolder As FolderInfo = New FolderInfo(mySess)
                    newFolder.Create(parentFolder, VetID, EntryNameOption.None)
                    newFolder.Unlock()
                End If
                mySearch.Close()
                'Search for files in Case Folder
                mySearch = New Search(mySess)
                mySearch.Command = "{LF:Name=""*"", Type=""DB""} & {LF:LOOKIN=""" + ConfigurationManager.AppSettings("LaserficheCaseFolder") + "\\" + VetID + """}"
                mySearch.Run()
                Dim settings As SearchListingSettings = New SearchListingSettings()
                Dim results As SearchResultListing = mySearch.GetResultListing(settings)
                If (results.RowCount > 0) Then
                    For Each elr As EntryListingRow In results
                        Dim newRow As DataRow = dt.NewRow()
                        Dim entryID As Integer = CInt(elr.GetDatumAsString(2))
                        newRow(0) = entryID
                        Dim myEntry As DocumentInfo = Document.GetDocumentInfo(entryID, mySess)
                        If myEntry.PageCount = 0 Then
                            myEntry.Delete()
                        Else
                            Using myEntry
                                newRow(1) = myEntry.Name
                                Dim entryValues As FieldValueCollection = myEntry.GetFieldValues()
                                newRow(2) = If(entryValues("Date Received"), DBNull.Value)
                                newRow(3) = If(entryValues("Document Type"), DBNull.Value)
                            End Using
                            dt.Rows.Add(newRow)
                        End If
                    Next
                End If
                If Not mySess Is Nothing Then
                    mySess.LogOut()
                    mySess.Close()
                    mySess.Discard()
                End If
                mySess = Nothing
            End Using
        Catch er As Exception
            lblVetName.Text = "Error " + er.ToString
            WebMsgBox.Show("Error " + er.ToString)
        End Try