NTFS Permissions

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
 
W

Willy Denoyette [MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top