简体   繁体   English

C#使用WMI从COMAdmin.COMAdminCatalog访问数据

[英]C# access data from COMAdmin.COMAdminCatalog using WMI

Earlier I was using code as below to grab COM+ applications and verify that my app is running 之前我使用下面的代码来捕获COM +应用程序并验证我的应用程序正在运行

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. 我试图通过WMI进行连接,并从win32 wmi提供程序中获取COM +应用程序列表,但似乎无法实现,或者我做错了什么。

I would be pleased if someone could help me to get the list of applications from COMAdminCatalog using credentials. 如果有人可以帮助我使用凭据从COMAdminCatalog获取应用程序列表,我将感到高兴。

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: 更多细节:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM