Click here to Skip to main content
13,862,914 members
Click here to Skip to main content
Add your own
alternative version


36 bookmarked
Posted 3 Apr 2003

CNTFS - A simple lib for managing NTFS permissions and audit settings.

, 22 Oct 2003
Rate this:
Please Sign up or sign in to vote.
CNTFS is a simple lib for setting NTFS permissions and audit settings.

Sample Image - ACLEditor.jpg


CNTFS lib is a simple C++ wrapper for many of the Microsoft security calls such as: GetNamedSecurityInfo, GetAclInformation, AddAccessAllowedAceEx and many others. CNTFS is used to set NTFS permissions and audit settings on files and folders. It's a programmatic alternative to using utilities such as xcacls.exe.


The following methods are supported in the lib:

int DeleteDACL(CString & I_objPath, BOOL I_removeInheritance)

int DeleteSACL(CString & I_objPath, BOOL I_removeInheritance)

int RemoveInheritance(CString & I_objPath)

int TakeOwnership(CString & I_objPath, CString & I_newOwner)

int AddACEToDACL(CString & I_objPath, 
                 CString & I_securityPrincipal, 
                 DWORD I_objPermission)

int AddACEToSACL(CString & I_objPath, 
                 CString & I_securityPrincipal, 
                 DWORD I_objPermission,
                 BOOL I_auditSuccess,
                 BOOL I_auditFailure)


ACLEditor is a test application for the CNTFS lib. One of the more tricky aspects of CNTFS is the use of access mask flags. Winnt.h defines access mask flags that can be OR'd together. For example, the Modify permission consists of: FILE_GENERIC_READ | FILE_GENERIC_WRITE | FILE_GENERIC_EXECUTE | DELETE. Among other things, ACLEditor demonstrates the use of access masks in setting NTFS permissions.


Be sure to have the Microsoft Platform SDK in c:\program files\Microsoft SDK. The project settings will reference the include files directory. I've run the lib through Rational Purify so all the mem leaks should be gone.

Any comments or suggestions are welcome.


Version History

  • Version 1.1 - (Oct 23, 2003) Added support for modifying DACLs and SACLs on registry keys. Consolidated RemoveDACLInheritance and RemoveSACLInheritance into RemoveInheritance method by adding aclType enum.
  • Version 1.0 - (Apr 4, 2003) Initial Release.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Kevin Hilscher
Web Developer
Canada Canada
No Biography provided

You may also be interested in...


Comments and Discussions

BugDoes not work on Windows 7 Pin
rhythm16-May-12 8:37
memberrhythm16-May-12 8:37 
GeneralBug in ResolveSID Pin
brianbacon15-Jan-11 7:26
memberbrianbacon15-Jan-11 7:26 
GeneralMy vote of 4 :) Pin
Kushagra Tiwari3-Nov-09 23:57
memberKushagra Tiwari3-Nov-09 23:57 
QuestionDelete account Pin
Jack6910487121-Oct-08 3:53
memberJack6910487121-Oct-08 3:53 
GeneralCrash on FAT file system Pin
Member 36743904-Aug-08 3:07
memberMember 36743904-Aug-08 3:07 
QuestionCNTFS Java Example ? Pin
belaie_maqsood27-Apr-06 12:02
memberbelaie_maqsood27-Apr-06 12:02 
Generalhelp !! it's not working in this case Pin
Anonymous26-Aug-05 17:26
memberAnonymous26-Aug-05 17:26 
QuestionWhat about NetFileEnum() Pin
Alex Evans29-Oct-04 0:40
memberAlex Evans29-Oct-04 0:40 
GeneralPerfect Pin
Steve Schaneville21-Oct-03 8:22
memberSteve Schaneville21-Oct-03 8:22 
GeneralRe: Perfect Pin
Alex Evans29-Oct-04 0:43
memberAlex Evans29-Oct-04 0:43 
GeneralERROR- Missing More Files !!! Pin
Bill SerGio Jr.11-Apr-03 7:25
professionalBill SerGio Jr.11-Apr-03 7:25 
GeneralRe: ERROR- Missing More Files !!! Pin
Andreas S. Franci Gonçalves11-Apr-03 7:41
professionalAndreas S. Franci Gonçalves11-Apr-03 7:41 
GeneralRe: ERROR- Missing More Files !!! Pin
yaron_gvili18-Apr-04 7:10
memberyaron_gvili18-Apr-04 7:10 
QuestionRe: ERROR- Missing More Files !!! Pin
tlongman7-Jan-07 16:17
membertlongman7-Jan-07 16:17 
GeneralAddAccessAllowedAceEx - Only availabe on win 2000 and later Pin
Christoph Weber7-Apr-03 23:39
memberChristoph Weber7-Apr-03 23:39 
GeneralRe: AddAccessAllowedAceEx - Only availabe on win 2000 and later Pin
Kevin Hilscher8-Apr-03 17:53
memberKevin Hilscher8-Apr-03 17:53 
GeneralWarning: Code Won't Compile! Pin
Bill SerGio Jr.6-Apr-03 2:22
professionalBill SerGio Jr.6-Apr-03 2:22 
GeneralRe: Warning: Code Won't Compile! Pin
Ryan Binns6-Apr-03 5:02
memberRyan Binns6-Apr-03 5:02 
GeneralRe: Warning: Code Won't Compile! Pin
Bill SerGio Jr.7-Apr-03 7:06
professionalBill SerGio Jr.7-Apr-03 7:06 
GeneralRe: Warning: Code Won't Compile! Pin
Ryan Binns7-Apr-03 14:48
memberRyan Binns7-Apr-03 14:48 
GeneralRe: Warning: Code Won't Compile! Pin
Kevin Hilscher6-Apr-03 6:09
memberKevin Hilscher6-Apr-03 6:09 
GeneralRe: Warning: Code Won't Compile! Pin
Anonymous25-Jun-05 0:40
memberAnonymous25-Jun-05 0:40 
Generaldemo project size Pin
Stephane Rodriguez.5-Apr-03 5:45
memberStephane Rodriguez.5-Apr-03 5:45 
GeneralRe: demo project size Pin
Kevin Hilscher5-Apr-03 13:39
memberKevin Hilscher5-Apr-03 13:39 
Bill SerGio Jr.6-Apr-03 2:11
professionalBill SerGio Jr.6-Apr-03 2:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web06 | 2.8.190214.1 | Last Updated 23 Oct 2003
Article Copyright 2003 by Kevin Hilscher
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid