Replace all child object permissions with inheritable permissions from this object là gì
I am trying to enable "replace all child object permission entries with inheritable permission entries from this object" method using PowerShell, below is my Script Show
asked Apr 14 at 19:16
5 Below is the script I have created and it worked as expected. Thank you for your suggestions and help. To replace all child objects, I have used Get-ChildItem with -recurse and it worked. $objName = (Get-CimInstance -ClassName Win32_ComputerSystem).UserName.Split("\")[1] $objDir = "C:\Users\$objName\" $objUser = (Get-CimInstance -ClassName Win32_ComputerSystem).UserName $objAccount = New-Object System.Security.Principal.NTAccount($objUser) $objRule = $objUser,"FullControl","ContainerInherit,ObjectInherit","None","Allow" $objFileSec = New-Object System.Security.AccessControl.FileSecurity $objAccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule($objRule) $objFileSec.SetOwner($objAccount) $objAclSec = Get-Acl $objDir $objAclSec.SetAccessRuleProtection($true,$true) $objAclSec.PurgeAccessRules($objAccount) $objAclSec.SetAccessRule($objAccessRule) Get-ChildItem -Path $objDir | Set-Acl -AclObject $objAclSec $objAclSec.Access | Format-Table Pauseanswered Apr 21 at 13:01
Not the answer you're looking for? Browse other questions tagged windows powershell permissions filesystems acl or ask your own question.I have a share drive folder that people from all over the company are right-click moving files into it so another department can process them. As we know, the right-click move function will retain the NTFS permissions of the folder it came from, but this is causing the department that needs to process them to not be able to access them (until I go in and manually replace the child objects inheritable permissions). The "easy" answer to this is to
instruct people to copy/paste then delete, but if you worked with the staff I work with, you would understand why I am hoping to avoid that method if possible. So here is my thought... is there a script I could create/run in say a scheduled task that would periodically run the Security>Advanced>Replace all child object permission entries with inheritable permission entries from this object? Or a better idea? I was thinking a tool like TerraCopy that might have
options you can configure so that the NTFS permissions are NOT retained during a move (which it does not appear Terracopy can do). I found this downloadable tool (https://helgeklein.com/setacl/), but I have never heard of it/them and not sure if I should trust it. Chào các bạn, trong bài viết này chúng ta sẽ cùng tiếp tục tìm hiểu về chủ đề phân quyền NTFS – NTFS Permission trên Windows Server 2012 nhé. Cũng như tiếp tục Series Tự Học MCSA 2012 tại website ‘Cuongquach.com‘. Contents
Khi xây dựng File server để user lưu trữ dữ liệu thì ta có nhu cầu thiết lập các quyền hạn, chức năng liên quan đến dữ liệu. Microsoft cung cấp cho ta bộ quyền NTFS (NTFS Permission) để thiết lập quyền trên dữ liệu đối với user Yêu cầu: dữ liệu phải được lưu trữ trên phân vùng có định dạng NTFS. Vậy nếu phân vùng đang ở định dạng FAT32 thì ta có thể dùng lệnh sau để chuyển từ định dạng FAT32 sang NTFS (lưu ý chuyển từ NTFS sang FAT, FAT32 dùng lệnh này không được). start -> run -> cmd convert [drive]: /FS:NTFSVí dụ: convert D: /FS:NTFSTạo Folder bất kì, chọn Properties, Tab Security: đây là giao diện của bộ quyền NTFS (còn gọi là ACL: Access Control List). ACLGiao diện gồm 2 phần:
2. Đặc điểm của NTFS permissionNTFS permission gồm có các đặc tính sau: NTFS permission gồm 2 nhóm chính:
2.1 Standard permissionStandard permission gồm 6 bộ quyền: – Read:
cho phép user đọc nội dung file. 2.1.1 Ví dụ về standard permission Tạo
4 user: KT1, KT2 thuộc group KeToan. NS1, NS2 thuộc group NhanSu. Yêu cầu: thiết lập quyền cho các folder.
Lưu ý: khi thực hiện phân quyền phải thực hiện từ folder cha di xuống. Chọn Users -> Remove. Xuất hiện thông báo: Không thể remove group Users vì group này đang chịu quyền thừa kế từ folder cha Để gỡ bỏ quyền thừa kế: Chọn Advance Chọn Disable inheritance Xuất hiện bảng thông báo: – Remove all inherited permission from this object: xóa tất cả các quyền thừa kế, các đối tượng trong ACL kể cả các group hệ thống (Creater Owner, System, Administrators). – Convert inherited permission into ….: giữ lại các đối tượng ở folder cha và folder con, nếu folder cha có group Ketoan thì folder con cũng có group Ketoan (khuyên nên dùng). => Remove thành công. Folder Data: add group KeToan, NhanSu và cho quyền Read and Execute. Folder Chung thừa kế các quyền và các đối tượng thì folder Data. Chọn Full Controll cho Group Ketoan, NhanSu Folder Ketoan: chọn Full Control cho Ketoan. Cách cấm group NhanSu (2 cách) Lưu ý:
(hạn chế deny cho đối tượng group vì nếu xảy ra trường hợp: “NS1” có nhu cầu vào folder Ketoan làm việc thì ta phải cấp quyền Read cho NS1 nhưng do group NhanSu bị deny nên deny ưu tiên hơn => NS1 không có quyền. Còn dùng cách trên thì chỉ cần add thêm NS1 rồi cấp quyền Read là xong ). Folder Nhansu làm tương tự . Cách Test quyền cho các user > Cách 1 (thực tế thường dùng): Chọn folder KeToan -> Tab security -> Advance -> Tab Effective Access Select a user: gõ vào KT1 -> view effective access Gõ vào User: NS1 > Cách 2: Đăng nhập vào từng user để test (!!!). Các lưu ý khi phân quyền: Tình huống 1: 2.2 Special PermissionSpecial Permission gồm 14 quyền: Full control: toàn quyền, giống Full control của
standar permission. This folder only: chỉ áp dụng quyền vào folder này ( các subfolder, file không bị áp đặt) Để thực hiện như ví dụ trên, ta chỉ cần cho group Ketoan quyền như hình: Đối với KT1 thì lại có toàn quyền trên folder, file do nó tạo ra. Vậy tại sao lại như thế ? Trước tiên ta phải tìm hiểu về Group định danh: – Là group quy định điều kiện để lấy member (thành viên). – Bao gồm: – Users (mặc định khi user tạo ra là thuộc group này) – Administrators. – System: group định danh hệ thống (mặc định full control). – Creator Owner: chứa member là những user tạo ra tài nguyên (ai tạo ra tài nguyên thì người đó thuộc nhóm Creator Owner trên tài nguyên đó) Group Creator Owner có quyền full control.Vì KT1 tạo ra KT1.txt => KT1 có quyền full control trên KT1.txt. Nếu mất Creator Owner thì không thể phân quyền. Tình huống 2: Administrator muốn đọc được KT1.txt thì phải làm cách nào ?? Administrator có 1 quyền rất đặc biệt là: Take ownership (chiếm sở hữu trên tài nguyên), chỉ có group administrators mới có. Administrator Properties: KT1.txt -> Advance Bấm Change: Chọn group, user muốn chiếm sở hữu. Lưu ý: Chỉ có Group Administrator có quyền take ownership (các user khác nếu có quyền full control cũng không thể take ownership) bởi vì hệ thống có 1 policy: Computer configuration -> Windows Setting -> Security Setting -> Local policy -> User right assignment Take ownership of files or other object (mặc định Administrator).Cách áp permission của 1 folder lên mọi tài nguyên bên trong nó. Properties: folder KeToan -> Tab security -> Advance: Check vào Replace all child object permission entries with inheritable permission entries from this object.Mình xin kết thúc bài viết “Tự học MCSA 2012 NTFS Permission“. Mình đã cố gắng nói những gì chi tiết nhất. Nếu có thắc mắc các bạn xin để lại câu hỏi. |