【问题标题】:VB.Net - Local WMI Connection with user credentialsVB.Net - 具有用户凭据的本地 WMI 连接
【发布时间】:2011-11-21 21:27:10
【问题描述】:

在 VB.Net 中,我尝试使用不同的凭据(用户没有管理员权限)连接到本地计算机上的 WMI,但出现此异常:

« 用户凭据不能用于本地连接 »

代码如下:

    Dim path As ManagementPath = Nothing
    Dim options As ConnectionOptions = Nothing
    Dim scope As ManagementScope = Nothing

    path = New ManagementPath("\\" & vServerName & "\root\CIMV2")

    options = New ConnectionOptions
    options.Username = vUsername
    options.Password = vPassword

    Scope = New ManagementScope(path, options)

    Scope.Connect()

【问题讨论】:

    标签: vb.net wmi local


    【解决方案1】:

    我知道这个问题很老,但我尝试了上述步骤,但没有奏效。我发现工作是这样的:

    https://web.archive.org/web/20150213044821/http://www.manageengine.com/network-monitoring/help/troubleshoot_opmanager/troubleshoot_wmi.html

    80041064 - 用户凭据不能用于本地连接

    原因

    当您指定监控运行OpManager的机器的用户名和密码时遇到此错误。

    解决方案

    不要为本地主机指定用户名和密码。要解决此问题,请从设备快照页面的“密码”链接中删除配置的用户名和密码。

    【讨论】:

    • 页面不存在了
    【解决方案2】:

    当没有管理员权限的用户当前登录时,您无权访问某些 wmi 实例。(这仅适用于本地 WMI 连接)

    MSDN reference on the topic

    真的很烂!但是,如果您可以以管理员组成员的用户身份运行您的应用程序,那么您的问题应该得到解决。

    补充说明:

    If you write a windows service with **local system** user, then you'll have full access to all wmi classes.


    注意:我已尝试授予我的受限用户适当的权限以访问所需的 wmi 操作,但它似乎不是那样工作的。在这种情况下,您必须在以下 3 个地方设置权限:

    1. Start->Run->dcmoncnfg->Component Services->Computers->My Computer->Properties->COM security tab
    2. Start->Run->dcmoncnfg->Component Services->Computers->My Computer->DCOM Config->Windows Management and Instrumention->Properties->Security tab
    3. Start->Run->wmimgmt.msc->WMI Control(Local)->Properties->Root(just highlight)->Security tab

    【讨论】:

      【解决方案3】:

      通过输入 wmic 进入 wmic 提示符,然后回车。然后输入:

      /user:""
      

      这将使尝试运行命令的用户无效。你可能需要对密码做类似的事情,我不知道。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-10-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-05-20
        相关资源
        最近更新 更多