Search code examples
c#asp.netoledbindexing-service

Check if Microsoft OLE DB Provider for Index Server (aka Provider=MSIDXS) is installed?


I use Windows Server 2008 R2 and ASP.NET 4.6.1.

How can I check if Microsoft OLE DB Provider for Index Server (Provider=MSIDXS) is installed ?

Maybe get a list the OLEDB providers available in the system.


Solution

  • I try this code.

    I don't know now if applies to all 32bit and 64bit providers.

    Guid for CLSID OLEDB is C8B522D0-5CF3-11ce-ADE5-00AA0044773D

    internal static Guid IID_IUnknown = new Guid("00000000-0000-0000-c000-000000000046");
    internal static Guid CLSID_DataLinks = new Guid("2206CDB2-19C1-11d1-89E0-00C04FD7A829");
    internal static Guid CLSID_OLEDB_ENUMERATOR = new Guid("C8B522D0-5CF3-11ce-ADE5-00AA0044773D");
    internal static Guid CLSID_MSDASQL_ENUMERATOR = new Guid("C8B522CD-5CF3-11ce-ADE5-00AA0044773D");
    
    
    private string GetOLEDBProvidersRegistered()
    {
        var res = "";
        try
        {
            Guid guidOleDbEnum = new Guid("{C8B522D0-5CF3-11ce-ADE5-00AA0044773D}");
    
            Type type = Type.GetTypeFromCLSID(guidOleDbEnum);
    
            using (OleDbDataReader rdr = OleDbEnumerator.GetEnumerator(type))
            {
                while (rdr.Read())
                    //Console.WriteLine("{0} - {1}", rdr["SOURCES_NAME"], rdr["SOURCES_DESCRIPTION"]);
                    res += string.Format("{0} - {1}\r\n", rdr["SOURCES_NAME"], rdr["SOURCES_DESCRIPTION"]);
    
            }
        }
        catch (Exception ex)
        {
            res = ex.Message;
        }
        return res;
    }