2

いくつかの DCOM 設定を変更するために小さな exe を作成しました。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
4

1 に答える 1

0

あなたのプログラムを Windows 7 で実行しようとしましたが、同じ問題が発生しました。最初は、モニカー文字列Securityのパラメーターを追加すると問題が解決すると思っていましたが、そうではありませんでした。次に、プログラムを管理者として実行したところ、機能しました。そのため、セキュリティ特権が欠落しているようです。

于 2011-02-04T19:09:11.827 に答える