Adrift in .Net
Imports CissoImports System.Security.PrincipalImports System.Data.OleDb Private Function GetIndexResults(ByVal Query As String) As DataTable Dim Q As New CissoQueryClass Dim util As CissoUtilClass Dim da As New OleDbDataAdapter Dim ds As New DataSet("IndexServerResults") Q.Query = Query Q.SortBy = "rank[d]" Q.Columns = "filename, rank, write" Q.Catalog = "query://DocumentServer/Resumes" Q.MaxRecords = 1000 util.AddScopeToQuery(Q, "\", "deep") Q.LocaleID = util.ISOToLocaleID("EN-US") Dim impContext As WindowsImpersonationContext = impersonateAnonymous() da.Fill(ds, Q.CreateRecordset("nonsequential"), "IndexServerResults") Q = Nothing util = Nothing impContext.Undo() Return myDS.Tables("IndexServerResults") End Function
Private Function GetIndexResults(ByVal Query As String) As DataTable Dim Q As New CissoQueryClass Dim util As CissoUtilClass Dim da As New OleDbDataAdapter Dim ds As New DataSet("IndexServerResults") Q.Query = Query Q.SortBy = "rank[d]" Q.Columns = "filename, rank, write" Q.Catalog = "query://DocumentServer/Resumes" Q.MaxRecords = 1000 util.AddScopeToQuery(Q, "\", "deep") Q.LocaleID = util.ISOToLocaleID("EN-US") Dim impContext As WindowsImpersonationContext = impersonateAnonymous() da.Fill(ds, Q.CreateRecordset("nonsequential"), "IndexServerResults") Q = Nothing util = Nothing impContext.Undo() Return myDS.Tables("IndexServerResults") End Function
The impersonateAnonymous function is described in a previous post of mine. In our case the anonymous user on the machine has appropriate privledges to query the remote Indexing Service, but the ASP.Net worker process does not so impersonation is in order for the function. That part is probably optional depending on the situation. The rest of it is not very tricky. I tried to fill the DataTable directly without the DataAdapter, but that didn't work. The CreateRecordset function of the CissoQueryClass returns an ADO recordset and I couldn't find a cast that worked. The DataAdapter seems to be doing the casting work during the call to Fill.
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.