Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Blocking NTFS permission inheritance using a command line

Status
Not open for further replies.

LordJudas

Technical User
Apr 18, 2002
11
US
I'm looking for a solution to stop NTFS inheritance on a folder like c:\users using a command line, a tool, a script.

I want to reset permission on this folder (do not copy actuals one).

Does anyone know a solution ?
 
there is a adssecurity dll available as part of the adsi resource kit, you may want to look at it if you are scripting ntfs security on files and folders. its is the nuts. great for generating audit info on file and folder permissions during server migrations, if you are brave enough you can use the old audits to set permissions on the new servers etc.

Const ADS_RIGHT_GENERIC_READ = &H80000000
Const ADS_RIGHT_GENERIC_EXECUTE = &H20000000
Const ADS_ACETYPE_ACCESS_ALLOWED = 0

Set sec = CreateObject("ADsSecurity")

Set sd = sec.GetSecurityDescriptor("FILE://c:\public\specs")
Set dacl = sd.DiscretionaryAcl

'-- Show the ACEs in the DACL ----
For Each ace In dacl
wscript.echo ace.Trustee
wscript.echo ace.AccessMask
wscript.echo ace.AceType
Next

Set ace = CreateObject("AccessControlEntry")
ace.Trustee = "ARCADIABAY\jsmith"
ace.AccessMask = ADS_RIGHT_GENERIC_READ Or ADS_RIGHT_GENERIC_EXECUTE
ace.AceType = ADS_ACETYPE_ACCESS_ALLOWED

dacl.AddAce ace
sd.DiscretionaryAcl = dacl
sec.SetSecurityDescriptor sd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top