C# access data from COMAdmin.COMAdminCatalog using WMI

1.6k Views Asked by At

Earlier I was using code as below to grab COM+ applications and verify that my app is running

COMAdmin.COMAdminCatalog catalog = new COMAdmin.COMAdminCatalogClass();
catalog.Connect(servername);
catalog.GetCollection("Applications")

Now I need to perform the same actions but from other domain. So when I try to run the code above I receive authentication error. I have tried to connect via WMI and grab list of COM+ applications from win32 wmi providers, but it seems that it's either not possible or I am doing smth wrong.

I would be pleased if someone could help me to get the list of applications from COMAdminCatalog using credentials.

1

There are 1 best solutions below

0
On BEST ANSWER

You will have to impersonate a different user on the current thread.

using (ImpersonatedUser user = new ImpersonatedUser("USER_NAME", "DOMAIN_NAME", "USER PASSWORD"))
{

    COMAdmin.COMAdminCatalog objCatalog = new COMAdmin.COMAdminCatalog();
    objCatalog.Connect("SERVER_NAME");

    COMAdmin.COMAdminCatalogCollection objAppCollection =
        (COMAdmin.COMAdminCatalogCollection) objCatalog.GetCollection("Applications");

    objAppCollection.Populate();

}

For more details: