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.
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:
ImpersonatedUser
class: https://blogs.msdn.microsoft.com/joncole/2009/09/21/impersonation-code-in-c/How to impersonate
: https://blogs.msdn.microsoft.com/shawnfa/2005/03/21/how-to-impersonate/