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 / 问题 / 480802
Accepted
colealtdelete
colealtdelete
Asked: 2013-02-21 10:59:12 +0800 CST2013-02-21 10:59:12 +0800 CST 2013-02-21 10:59:12 +0800 CST

将 OU 权限从现有安全组复制到新安全组

  • 772

目前我们有一个名为:Limited_IT_Admins 的安全组,它对一个国家 OU 中的约 7 个城市 OU 具有特殊权限(仅限于他们可以执行的某些任务)。

[Country] <- top level OU
  [City01]
  [City02]
  [City03]
  [City04]
  [City05]
  [City06]
  [City07]

但是,现在我必须将这个安全组分成三个单独的组。来自 Limited_IT_Admin 组的用户将被分成三个独立的新组。用户将需要与 Limited_IT_Admins 相同的访问权限,但仅限于他们各自的 OU。

Limited_IT_Admin_01 - User01
  City01, City02, City03

Limited_IT_Admin_02 - User02
  City04, City05

Limited_IT_Admin_03 - User03
   City06, City07

不必尝试重新创建在安全组上设置的所有特殊权限,有没有更简单的方法将 Limited_IT_Admins 拥有的权限复制到三个新组?

active-directory
  • 2 2 个回答
  • 9500 Views

2 个回答

  • Voted
  1. Best Answer
    jscott
    2013-02-27T05:35:18+08:002013-02-27T05:35:18+08:00

    我已经创建了一个 Powershell 函数Copy-DsAcl,它应该有助于执行这种 Active Directory 权限复制。使用此功能,原始答案(在线下方)可以更干净地重写为:

     Import-Module ActiveDirectory
    
     # Dot source the Copy-DsAcl function: https://github.com/jasonkeithscott/Copy-DsAcl
     . .\Copy-DsAcl.ps1
    
     # Reference objects
     $sourceGroup    = Get-ADGroup Limited_IT_Admins
     $sourceObject   = Get-ADOrganizationalUnit -Filter { Name -eq "City01" }
    
     # Hash for the new groups and their assigned OUs
     $targetGroups   = @{}
     $targetGroups.Add("Limited_IT_Admin_01", @("City01", "City02", "City03"))
     $targetGroups.Add("Limited_IT_Admin_02", @("City04", "City05"))
     $targetGroups.Add("Limited_IT_Admin_03", @("City06", "City07"))
    
     # Walk each targetGroup in the hash
     foreach ( $g in $targetGroups.GetEnumerator() ) {
    
         $targetGroup = Get-ADGroup $g.Name
    
         # Walk each $city OU and add the $targetGroup to the ACL
         foreach ( $city in $g.Value ) {
    
             Write-Host "Adding $($g.Name) to $city"
             $targetObject = Get-ADOrganizationalUnit -Filter { Name -eq $city }
             Copy-DsAcl $sourceGroup $sourceObject $targetGroup $targetObject
    
         }
    
     }
    

    下面的 Powershell 应该可以满足您的要求。有几个要求:

    1. 您需要 Microsoft ActiveDirectory Powershell 模块。它包含在 RSAT7 中。
    2. 您需要为您的环境更新以下内容:
      1. $root- PSDrive 到您的“根”OU。您问题中的“国家”。
      2. $sourceOU- 您将从中复制 ACE 的源 OU(名称,而非 DN)。
      3. $sourceGroup- 您将复制的 ACL 中列出的组(名称,不是 DN 或域)。
      4. $targetGroups- 用于应用 ACE 的组(名称,而非 DN 或域)和 OU(名称,而非 DN)的散列。
    3. 这只会复制显式 ACE,而不是继承的。也许我应该看看爬上树去抓住继承的?
    4. 由于出现“拒绝访问”错误,我不得不以域管理员身份运行它。不过,我最初的 OU 代表团可能是可疑的。

    通读所有这些内容后,我认为我可能应该只编写一个更通用的函数,CopyOuAcl并在完成后对其进行更新。正如现在所写的那样,它完全针对您的问题和环境。

    Import-Module ActiveDirectory
    
    $root          = "AD:\OU=Country,DC=example,DC=com"
    $sourceOU       = "City01"
    $sourceACL      = Get-Acl $root.Replace("AD:\", "AD:\OU=$sourceOU,")
    $sourceGroup    = "Limited_IT_Admins"
    
    # Hash for the new groups and their OUs
    $targetGroups = @{}
    $targetGroups.Add("Limited_IT_Admin_01", @("City01", "City02", "City03"))
    $targetGroups.Add("Limited_IT_Admin_02", @("City04", "City05"))
    $targetGroups.Add("Limited_IT_Admin_03", @("City06", "City07"))
    
    # Get the uniherited ACEs for the $sourceGroup from $sourceOU
    $sourceACEs = $sourceACL |
        Select-Object -ExpandProperty Access |
            Where-Object { $_.IdentityReference -match "$($sourceGroup)$" -and $_.IsInherited -eq $False }
    
    # Walk each targetGroup in the hash
    foreach ( $g in $targetGroups.GetEnumerator() ) {
    
        # Get the AD object for the targetGroup
        Write-Output $g.Name
        $group      = Get-ADGroup $g.Name
        $identity   = New-Object System.Security.Principal.SecurityIdentifier $group.SID
    
        # Could be multiple ACEs for the sourceGroup
        foreach ( $a in $sourceACEs ) {
    
            # From from the sourceACE for the ActiveDirectoryAccessRule constructor  
            $adRights               = $a.ActiveDirectoryRights
            $type                   = $a.AccessControlType
            $objectType             = New-Object Guid $a.ObjectType
            $inheritanceType        = $a.InheritanceType
            $inheritedObjectType    = New-Object Guid $a.InheritedObjectType
    
            # Create the new "copy" of the ACE using the target group. http://msdn.microsoft.com/en-us/library/w72e8e69.aspx
            $ace = New-Object System.DirectoryServices.ActiveDirectoryAccessRule $identity, $adRights, $type, $objectType, $inheritanceType, $inheritedObjectType    
    
            # Walk each city OU of the target group
            foreach ( $city in $g.Value ) {
    
                Write-Output "`t$city"
                # Set the $cityOU
                $cityOU = $root.Replace("AD:\", "AD:\OU=$city,")
                # Get the ACL for $cityOU
                $cityACL = Get-ACL $cityOU
                # Add it to the ACL
                $cityACL.AddAccessRule($ace)
                # Set the ACL back to the OU
                Set-ACL -AclObject $cityACL $cityOU
    
            }
    
        }
    
    }
    
    • 3
  2. Copy Run Start
    2013-02-21T12:06:21+08:002013-02-21T12:06:21+08:00

    http://gallery.technet.microsoft.com/scriptcenter/Copying-permissions-for-d3c3b839

    或者只是复制 NtSecurityDescriptor。http://blogs.msdn.com/spatdsg/archive/2007/05/24/copying-delegation-permissions-from-an-ou-to-another.aspx

    • 0

相关问题

  • 如果以域用户身份远程登录,PC 速度极慢

  • 如何在 Windows 2003 的 ou 级别应用策略

  • 允许用户更改其 Active Directory 密码的 Web 界面

  • MOSS 2007 无法使用 ActiveDirectoryMembershipProvider 配置表单身份验证

  • 通过 VPN 更改 Active Directory 密码

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