简体   繁体   English

将安全AD组添加到文件夹权限,而不允许继承

[英]Add Security AD Groups to folder permission without allowing Inheritance

I am adding ADGroups to folder permissions (Permissions are being applied correctly). 我正在将ADGroups添加到文件夹权限(正确应用权限)。 How can I prevent the ADGroups that I am adding from inheriting? 如何防止继承的ADGroups?

I have tried just about everything and variation IG 我已经尝试过几乎所有的东西和变异IG

$InheritanceFlag=[System.Security.AccessControl.InheritanceFlags]@("ContainerInherit,ObjectInherit") $InheritanceFlag=[System.Security.AccessControl.InheritanceFlags]::"ContainerInherit,ObjectInherit" $InheritanceFlag=[System.Security.AccessControl.InheritanceFlags]"ContainerInherit,ObjectInherit" $InheritanceFlag=[System.Security.AccessControl.InheritanceFlags]"ContainerInherit" $InheritanceFlag=[System.Security.AccessControl.InheritanceFlags]"ObjectInherit" $InheritanceFlag=[System.Security.AccessControl.InheritanceFlags]@("ContainerInherit,ObjectInherit") $InheritanceFlag=[System.Security.AccessControl.InheritanceFlags]::"ContainerInherit,ObjectInherit" $InheritanceFlag=[System.Security.AccessControl.InheritanceFlags]"ContainerInherit,ObjectInherit" $InheritanceFlag=[System.Security.AccessControl.InheritanceFlags]"ContainerInherit" $InheritanceFlag=[System.Security.AccessControl.InheritanceFlags]"ObjectInherit"

Also tried the following combinations with the above. 还尝试了以上与上述组合。

$PropagationFlag=[System.Security.AccessControl.PropagationFlags]"None" $PropagationFlag=[System.Security.AccessControl.PropagationFlags]::None $PropagationFlag=[System.Security.AccessControl.PropagationFlags]::InheritOnly $PropagationFlag=[System.Security.AccessControl.PropagationFlags]::NoPropagateInherit $PropagationFlag=[System.Security.AccessControl.PropagationFlags]"None" $PropagationFlag=[System.Security.AccessControl.PropagationFlags]::None $PropagationFlag=[System.Security.AccessControl.PropagationFlags]::InheritOnly $PropagationFlag=[System.Security.AccessControl.PropagationFlags]::NoPropagateInherit

And also with quotes. 并且还有引号。 In addition to: 此外:

$ACL.SetAccessRuleProtection($true,$true) |Set-Acl $sFoldPath $ACL.SetAccessRuleProtection($false,$false) |Set-Acl $sFoldPath $ACL.SetAccessRuleProtection($true,$false) |Set-Acl $sFoldPath $ACL.SetAccessRuleProtection($true,$true) |Set-Acl $sFoldPath $ACL.SetAccessRuleProtection($false,$false) |Set-Acl $sFoldPath $ACL.SetAccessRuleProtection($true,$false) |Set-Acl $sFoldPath

I have been at this for 4/5 days and have load just about every link on the 1st 2 pages of my various search results. 我已经在这里工作了4/5天,并且在我的各种搜索结果的前2页上加载了几乎每个链接。 Plus last night and today researched every suggestion from StackOverflow before posting here for help. 加上昨晚和今天研究了StackOverflow的每一个建议,然后在这里寻求帮助。

I am at a complete loss as to what I am not doing correctly and am now reaching out to the community for any help or insights that you could provide. 我完全失去了我正在做的事情,现在我正在向社区寻求您可以提供的任何帮助或见解。


$InheritanceFlag=[System.Security.AccessControl.InheritanceFlags]@("ContainerInherit,ObjectInherit") # "ContainerInherit,ObjectInherit"
$PropagationFlag=[System.Security.AccessControl.PropagationFlags]"None" # "InheritOnly" # NoPropagateInherit # This property is significant only when the value of the InheritanceFlags enumeration is not None.
$AccessControlType=[System.Security.AccessControl.AccessControlType]"Allow "


    ForEach ($oCol in $oCSVData){
                   $sFoldPath=$oCol.'FolderPath'.Trim()           
           $IdentityReference=$oCol.'GroupNames'.Trim()

If ($IdentityReference.Substring($IdentityReference.Length - 2) -eq '_R') {
        $sPermission= ('ReadAndExecute','Read','ListDirectory')
  }  Else {
        $sPermission='Modify' 
} 

$ACL = Get-Acl $sFoldPath

$AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule($IdentityReference,$sPermission,$InheritanceFlag,$PropagationFlag,'Allow')

$ACL.SetAccessRuleProtection($true,$true)

$ACL.AddAccessRule($AccessRule) 

$ACL | Set-Acl $sFoldPath
    }

My requirements are that I need to associate an AD Group with a folder, assign the permissions and make sure the AD Groups permissions are visible in the context window; 我的要求是我需要将AD组与文件夹相关联,分配权限并确保AD组权限在上下文窗口中可见; and not being assigned as special permissions. 并且未被指定为特殊权限。 Lastly, the Ad Groups permissions are not being inherited. 最后,广告组权限未被继承。

I have a script that does almost the exact same thing that you are asking for. 我有一个脚本几乎完全与你要求的相同。 Here is what I have found that works: 这是我发现的工作原理:

$folderACL = Get-ACL (Path\to\folder)

$inherit = [system.security.accesscontrol.InheritanceFlags]"ContainerInherit, ObjectInherit"
$propagation = [system.security.accesscontrol.PropagationFlags]"None"

$accessRule = New-Object system.security.accesscontrol.filesystemaccessrule("Domain\User","Modify", $inherit, $propagation, "Allow")

$folderACL.SetAccessRule($accessRule)

#Set folder inheritance to off
$folderAcl.SetAccessRuleProtection($True,$false)

Set-Acl (Path\to\folder) -AclObject $folderAcl

If you are looking for users to be able to view the contents of the directory, and be able to access files within that directory you only need the ObjectInherit inheritance flag, and no propagation flags. 如果您正在寻找能够查看目录内容的用户,并且能够访问该目录中的文件,则只需要ObjectInherit继承标志,并且不需要传播标志。 It sounds like you are just trying to add access to a specific folder for a specific group, so unless you are trying to removed inherited rights (such as, do you really want to remove rights for the SYSTEM account, or Domain Admins?) you can skip the SetAccessRuleProtection step. 听起来你只是想尝试为特定组添加对特定文件夹的访问权限,所以除非你试图删除继承的权限(例如,你真的想要删除SYSTEM帐户或Domain Admins的权限吗?)你可以跳过SetAccessRuleProtection步骤。 I think this should do what you want: 我认为这应该做你想要的:

$InheritanceFlag=[System.Security.AccessControl.InheritanceFlags]"ObjectInherit" # ObjectInherit ensurs only objects are accessable, not subfolders
$PropagationFlag=[System.Security.AccessControl.PropagationFlags]"NoPropagateInherit"

ForEach ($oCol in $oCSVData){
    $sFoldPath=$oCol.'FolderPath'.Trim()           
    $IdentityReference=$oCol.'GroupNames'.Trim()

    $sPermission= If ($IdentityReference.Substring($IdentityReference.Length - 2) -eq '_R') {
         'ReadAndExecute,ListDirectory'
    }  Else {
         'Modify' 
    } 

    $ACL = Get-Acl $sFoldPath

    $AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule($IdentityReference,$sPermission,$InheritanceFlag,$PropagationFlag,'Allow')

    $ACL.AddAccessRule($AccessRule) 

    $ACL | Set-Acl $sFoldPath
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将文件夹安全性链接到AD安全组Powershell脚本 - Linking folder security to AD security groups Powershell script 使用Powershell将电子邮件地址添加到AD安全组 - Add email addresses to AD security groups using Powershell PowerShell:如何将 1 个用户添加到多个 Active Directory 安全组 - 具有写入权限的安全组的安全选项卡 - PowerShell: How to add 1 user to multiple Active Directory Security Groups - Security tab of the security group with write permission 如何在AD中循环访问OU以将用户添加到各种安全组? - How can I loop through OU in AD to add users to various security groups? 将 Azure AD 用户添加到 Azure AD 组 - Add Azure AD users to Azure AD groups 在网络文件夹上查找 AD 安全组 - Find AD security groups on network folders Azure AD 自定义安全属性和动态组 - Azure AD Custom Security Attributes & Dynamic Groups 创建文件夹,创建AD组,将组应用于文件夹并设置权限 - Create Folder, Create AD Groups, Apply Groups to Folder and Set Permissions Powershell - 如果不是多个组的成员,则将 OU 中的用户广告到安全组 - Powershell - Ad user from OU to Security groups if not members of several groups PowerShell:将用户添加到AD并将其添加到组中 - PowerShell: Add Users to AD and Add them in Groups
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM