首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >wmi SetSecurityDescriptor

wmi SetSecurityDescriptor
EN

Stack Overflow用户
提问于 2016-12-19 14:38:46
回答 2查看 411关注 0票数 0

尝试使用sddl通过wmi授予对systemroot的访问权限,但获得无效参数的错误。这是我的职责:

代码语言:javascript
复制
function GrantSysRoot
{
    Param (
        [string]$strcomputer
    )  
    $sec =  Get-WmiObject -Class Win32_LogicalFileSecuritySetting -Filter "Path='C:\\Windows'" -ComputerName $strcomputer
    $converter = New-Object System.Management.ManagementClass Win32_SecurityDescriptorHelper
    $sddl = $converter.Win32SDToSDDL($sec.GetSecurityDescriptor().Descriptor)
    $newSDDL = $sddl.SDDL += "(" + $SRSDDL + ")"
    $Win32descriptor = $converter.SDDLToWin32SD($newSDDL)
    $result = $sec.SetSecurityDescriptor($Win32descriptor)

    if ($result.ReturnValue -eq 0) {
        LogWrite "Success SystemRoot setting rights"
    } 
    else {
        LogWrite "An error occured with SystemRoot rights settings"
    }
}

SetSecurityDescriptor方法返回无效的参数错误。有什么想法吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-12-20 07:48:14

解决后,我们必须使用属性“描述符”。

代码语言:javascript
复制
$result = $sec.SetSecurityDescriptor($Win32descriptor.Descriptor)
票数 0
EN

Stack Overflow用户

发布于 2016-12-19 15:41:18

我觉得你做了个小错误。在您的代码中,我无法看到用$SRSDDL定义的任何内容,但是您正在追加数据并以$newSDDL存储。你能再确认一下吗。

代码语言:javascript
复制
function GrantSysRoot
{
Param (
[string]$strcomputer
 )  
 $sec =  Get-WmiObject -Class Win32_LogicalFileSecuritySetting -Filter "Path='C:\\Windows'" -ComputerName $strcomputer
 $converter = new-object system.management.ManagementClass Win32_SecurityDescriptorHelper
 $sddl = $converter.Win32SDToSDDL($sec.GetSecurityDescriptor().Descriptor)
 $newSDDL = $sddl.SDDL += "(" + $SDDL + ")"
 $Win32descriptor = $converter.SDDLToWin32SD($newSDDL)
 $result = $sec.SetSecurityDescriptor($Win32descriptor)
 if ($result.ReturnValue -eq 0){LogWrite "Success SystemRoot setting rights"
    } else {LogWrite "An error occured with SystemRoot rights settings"}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41224963

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档