AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 833749
Accepted
the-wabbit
the-wabbit
Asked: 2017-02-21 08:42:55 +0800 CST2017-02-21 08:42:55 +0800 CST 2017-02-21 08:42:55 +0800 CST

“权限被拒绝”以非管理员身份创建新的基于域的 Dfs 根

  • 772

我的任务是将我们领域中的一些日常任务委派给一群没有Domain Admins会员资格的技术人员。其中一项任务是创建新的基于域的 Dfs 根(Server 2008 R2 Enterprise DC)。这就是我卡住的地方。

c0de

这基本上只是试图创建一个基于域的 Dfs 根,使用任意(列表中的第一个)域控制器作为第一个命名空间服务器:

$DfsnRootName="test"
$DCList = Get-ADDomainController -Filter * | ForEach-Object { ,$_.HostName } 
New-DfsnRoot -Path "\\domain.contoso.com\$DfsnRootName" -TargetPath "\\$($DCList[0])\$dfsnRootName" `
             -Description "Dfs-Root für $DfsnRootName" -EnableAccessBasedEnumeration $true -Type DomainV2
$DCList | ForEach-Object {
    New-DfsnRootTarget -Path "\\domain.contoso.com\$DfsnRootName" `
                       -TargetPath "\\$_\$dfsnRootName" -State Online
}

错误0r

上面的代码抛出一个异常,提到缺少对 CIM 资源的访问权限。CategoryInfoROOT\Microsoft\Windows\DFSN\MSFT_DFSNamespace中给出的路径类似于 WMI 路径:

New-DfsnRoot : Access to a CIM resource was not available to the client.
At line:1 char:1
+ New-DfsnRoot -Path "\\domain.contoso.com\$DfsnRootName" -TargetPath "\\$($DCList ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (MSFT_DFSNamespace:ROOT\Microsoft\...FT_DFSNamespace) [New-DfsnRoot], CimException
    + FullyQualifiedErrorId : MI RESULT 2,New-DfsnRoot


PS Z:\> $Error[0].CategoryInfo


Category   : PermissionDenied
Activity   : New-DfsnRoot
Reason     : CimException
TargetName : MSFT_DFSNamespace
TargetType : ROOT\Microsoft\Windows\DFSN\MSFT_DFSNamespace

无奈的 res0luti0n 尝试:

我通过 Dfs 控制台为整个域拥有“委派管理权限”: 委派管理权限截图

这实际上只是为添加到CN=Dfs-Configuration,CN=SystemAD 容器的主体添加“完全控制”ACE。

当我在使用“添加 Dfs root”向导时收到错误指示服务控制管理器上缺少权限时dfsmgmt.msc,我曾经sc sdset scmanager操纵 SDDL 字符串添加具有“KA”(密钥访问)权限的相应组,类似于BUILTIN\AdministratorsACE默认情况下存在。

这样,我可以使用“添加 Dfs 根”向导完成所有步骤,但根本身的创建仍然失败 - “无法添加命名空间服务器 \ADSRV0\Test。访问被拒绝”

W00吨?

powershell active-directory delegation
  • 3 3 个回答
  • 5396 Views

3 个回答

  • Voted
  1. Best Answer
    Matthew Wetmore
    2017-03-15T11:00:06+08:002017-03-15T11:00:06+08:00

    Just Enough Administration (JEA)端点非常适合您的任务。设计 JEA 端点需要三个主要决策:

    1. 谁可以调用 JEA 端点?
    2. 来电者能做什么?
    3. 通话将以谁的身份进行?

    PS 5.1 中的 PowerShell 端点在技术上不是 JEA 端点,但机制本质上是相同的。

    Get-PSSessionConfiguration
    名称:microsoft.powershell PSVersion:5.1
    StartupScript:
    RunAsUser:
    权限:NT AUTHORITY\INTERACTIVE AccessAllowed、BUILTIN\Administrators AccessAllowed、BUILTIN\Remote Management Users AccessAllowed

    由此,权限组定义了允许呼叫的人。PowerShell 端点可以做什么没有限制,因此您拥有完整的语言功能。最后,在 RunAsUser 为空白的情况下 - 代码运行模拟为用户或提供的凭据。

    在此基础上,查看 JEA 的帮助Register-PSSessionConfiguration和概述。

    对于奖励积分,请考虑使用组管理服务帐户 (GMSA)作为解决方案的一部分,尤其是作为呼叫者。

    在您的情况下: 您可以将端点限制为由您的有限权限用户调用。

    然后定义您希望他们使用的特定 cmdlet。这些可以内置,也可以从您指定的自定义模块中公开。保持这些特定于您的任务,以避免使用复杂参数的特权提升攻击或暴露的太多低级命令可以利用作为提升用户运行的优势。

    您可以使用RunAsUser域管理员或其他具有足够权限的帐户。

    • 2
  2. Peter Zhabin
    2017-03-08T13:58:34+08:002017-03-08T13:58:34+08:00

    要创建域范围的 DFS 命名空间,这样做的帐户应该在命名空间服务器上具有本地管理员权限,这就是ADSRV0您的情况。您的最后一条错误消息向我表明,您的情况并非如此。

    • 1
  3. the-wabbit
    2019-01-12T05:57:41+08:002019-01-12T05:57:41+08:00

    在这里,为了给 Matthew Wetmore 的想法添加一些实现细节,我们创建了一个函数来根据我们的要求设置 Dfs 命名空间,将其暴露在 Powershell 模块中LT-DFSManagement,并创建一个在“虚拟帐户”中运行的 Powershell 会话配置(其中正在获得本地管理员权限)在域控制器上被限制为调用此功能并且技术人员安全组的成员可以访问。

    我们在代码中使用它是为了在没有Dfsndfsutil -cmdlet的 Server 2008 R2 机器上运行而编写的。请注意,代码使用了一些默认情况下不会在您的环境中定义的全局变量,但对于正确执行代码至关重要。

    Function Add-DfsNamespace() {
    <#
    .SYNOPSIS
    Creates a new Dfs namespace
    #>
        Param(
            # Name of the namespace to create
            [string]$Name,
            # name of the security group to delegate management permissions to
            [string]$DelegationTo = "ACL-$Name-Dfs-management",
            # list of the servers to set up as namespace servers
            $NamespaceServerList = $global:DomainControllersList
        )
    
        $ErrorActionPreference = "Stop"
    
        Try { 
            $DelegationIdentity = (Get-ADGroup $DelegationTo -Server $global:THKDomainControllerToUse).SID
        } Catch {
            Throw "Unable to set up delegation permissions for $DelegationTo: $_"
        }
        $NamespaceServerList | ForEach-Object {
            Try {
                $NamespaceServer = $_
                Write-Debug "Create a directory for the namespace: \\$NamespaceServer\c$\DfsRoots\$Name"
                New-Item -Type Directory "\\$NamespaceServer\c$\DfsRoots\$Name" | Out-Null
            } Catch {
                Write-Warning "Creation of \\$NamespaceServer\c$\DfsRoots\$Name failed: $_"
            }
    
            # Create a new share through WMI
            $share = [wmiclass]"\\$_\root\CimV2:Win32_Share" 
            Write-Debug 'WMI call to create the share `"$Name`" on $_' 
            $result=$share.Create( "c:\DfsRoots\$Name", $Name, 0) 
            Switch ($result.returnValue) {
               0 { Write-Debug "\\$_\$Name share created successfully" }
               22 { Write-Warning "Share \\$_\$Name already present" }
               default { Throw "Share creation failed, return value of Win32_Share.Create: $result.returnValue" }
            }
        }
        Write-Verbose "Creating Domain Dfs namespace $Name on namespace servers $($NamespaceServerList -join "; ")"
        dfsutil root addDom "\\$($NamespaceServerList[0])\$Name"
        $NamespaceServerList | ForEach-Object {
            If($_ -ne $NamespaceServerList[0]) {
                dfsutil target add "\\$_\$Name"
            }
        }
        Write-Debug "Enabling Access-Based Enumeration"
        dfsutil property abde enable "\\$global:sADDomainFQDN\$Name"
        Write-Debug "Granting delegation rights for Namespace $Name to $DelegatedTo"
        $adsiDfsNamespace = $null
        $adsiDfsNamespace = [adsi]"LDAP://$global:THKDomainControllerToUse/CN=$Name,CN=Dfs-Configuration,CN=System,$sADDomainDN" 
        # Query ADSI for the ACL of the namespace AD object until we get a response
        $retries = 0
        Do {
            $namespaceACL = $adsiDfsNamespace.PSBase.ObjectSecurity
            If ($namespaceACL) {
                # here we've got the ACL, loop will end hereafter
            } Else {
                Write-Debug "Waiting another round ($retries/$ADSImaxRetries) as ADSI has not yet provided a security descriptor for $($adsiDfsNamespace)"
                Start-Sleep 1
            }
            $retries+=1
        } Until (($retries -gt $ADSImaxRetries) -or ($null -ne $namespaceACL))
    
        Write-Debug "Creating a new ACE for $DelegationTo ($DelegationIdentity)"
        # Construct a new Full Control ACE for $DelegationIdentity 
        $newAce =
            New-Object System.DirectoryServices.ActiveDirectoryAccessRule(
                $DelegationIdentity,
                [System.DirectoryServices.ActiveDirectoryRights]::GenericAll,
                [System.Security.AccessControl.AccessControlType]::Allow,
                [System.DirectoryServices.ActiveDirectorySecurityInheritance]::All
            )
    
        Write-Verbose "Updating the ACL of the Namespace $Name"
        $namespaceAcl.AddAccessRule($newAce)
        $adsiDfsNamespace.PSBase.CommitChanges()
    }
    

    PSSessionConfiguration 文件定义了此会话配置可用于的安全组:

    @{
        'Author' = 'the-wabbit';
        'RunAsVirtualAccount' =  $true;
    'GUID' = 'cfe0ea5f-9d19-406d-90aa-d26df4bc840f';
        'TranscriptDirectory' = 'C:\ProgramData\JEAConfiguration\Transcripts';
        'SchemaVersion' = '2.0.0.0';
        'RoleDefinitions' = @{
                                'DOMAIN\ACL-DFS-Technicians-AD-JEA-Remoting' = @{
                                                                                    'RoleCapabilities' = 'AD-JEA-DFS' }
                            };
        'SessionType' = 'RestrictedRemoteServer' }
    

    并且AD-JEA-DFS角色能力文件仅将端点限制为 Add-DfsNamespace 函数:

    @{
    GUID = 'b17b282d-a656-41c8-a7d4-cc6a1fbc17e4'
    Author = 'the-wabbit'
    CompanyName = 'Looney Tunes'
    Copyright = '(c) 2017 the-wabbit. All rights reserved.'
    ModulesToImport = 'LT-DFSManagement'
    VisibleFunctions='Add-DfsNamespace'
    }
    

    配置的最终注册使事情到位:

    Register-PSSessionConfiguration -Name "DFS" -Path "C:\ProgramData\JEAConfiguration\DFS.pssc"
    
    • 0

相关问题

  • 资源锁和电源外壳

  • 脚本 - 如何断开远程桌面会话?

  • 如何限制向通讯组发送到外部地址?

  • Powershell对值与数组的作用不同?

  • Windows Powershell Vim 键绑定

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve