我创建了一个小exe来修改一些DCOM设置。当我尝试修改运行exe的其他服务器上的设置但是当我尝试修改运行exe的同一服务器上的设置时,exe工作正常
代码在
之下如果我将strComputer设置为另一台远程计算机的名称,代码将工作并更新远程计算机上的正确设置
我在尝试更新同一服务器时运行此错误时得到的错误是我抛出的错误: - '无法获取安全描述符',返回码为-2147023582
非常感谢任何帮助。我已经把头撞到了墙上一会儿
Dim strComputer As String = "." 'localhost
Dim objWMIService As Object = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
' Get an instance of Win32_SecurityDescriptorHelper
Dim objHelper = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2:Win32_SecurityDescriptorHelper")
' Obtain an instance of the the class using a key property value.
Dim objApp As Object = objWMIService.Get("Win32_DCOMApplicationSetting.AppID='{E9E35B75-5B49-4C13-B928-239F78D695A6}'")
' Get the existing security descriptor for the App
Dim objSD As Object
Dim ret = objApp.GetLaunchSecurityDescriptor(objSD)
If ret <> 0 Then
Throw new ApplicationException("Could not get security descriptor: " & ret)
End If
' Convert file security descriptor from Win32_SecurityDescriptor format to SDDL format
Dim SDDLstring As String
ret = objHelper.Win32SDToSDDL(objSD, SDDLstring)
If ret <> 0 Then
Throw new ApplicationException("Could not convert to SDDL: " & ret)
End If
' Set the Launch security descriptor for the App
SDDLstring = SDDLstring & "(A;;CCDCLCSWRP;;;NS)"
ret = objHelper.SDDLToWin32SD(SDDLstring, objSD)
If ret <> 0 Then
Throw new ApplicationException("Could not translate SDDL String to Win32SD: " & ret)
End If
ret = objApp.SetLaunchSecurityDescriptor(objSD)
If ret <> 0 Then
Throw new ApplicationException("Could not set security descriptor: " & ret)
End If
答案 0 :(得分:0)
我尝试在Windows 7上运行您的程序并遇到同样的问题。最初我认为添加Security
参数Moniker string可以解决问题,但事实并非如此。然后,我以管理员身份运行您的程序,它运行正常。所以似乎缺少一些安全权限。