NTFS Permissions

  • Thread starter Thread starter Tim Law
  • Start date Start date
T

Tim Law

Is there a way to set NTFS file permissions using C#?

From my program I want to be able to set the users that
can access a specific file. I can accomplish this by
right clicking on the file from explorer, select the
security tab, delete all the other users and groups that
have permissions and add my users to the permissions
list. However, I want to do this from my program rather
than by using explorer.

Thanks,
Tim
 
Jop Pascual said:
Yes there is; but it is not as simple as one might think.

This (http://tinyurl.com/nrcp) shows you how to do it using
DirectoryServices, this (http://tinyurl.com/nrd1) shows
the same using System.Management, and another one
(http://tinyurl.com/nrdb) that uses P/Invoke to access the
ACL and ACE information. Unfortunately, .NET does not
have this functionality yet...

And when it will have it, it will be as complex as using both the DirectoryServices or the Management classes :-)
The reason for this is that ACL programming is a tricky and complex matter, therefore I would suggest don't do it unless you really
understand how security management on objects is implemented in Windows.
The best option is to use the available command-line tools like CACLS.EXE

Willy.
 
Back
Top