By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,246 Members | 1,553 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,246 IT Pros & Developers. It's quick & easy.

Removing NTFS Folder Permissions On Win2000 In .NET Without using WMI

P: n/a
Ram
Hey,
I'v managed to find a way of adding NTFS permissions to a certain folder,
But the problem is, the folder has a couple of inherited permissions which I
want to delete.
How can I remove the folder's NTFS permissions WITHOUT using WMI or special
XP features?
Thanks ahead!

--Ram
Nov 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

look for a library called <ADsSecurity.dll> in
msdn.microsoft.com/google.com;

this will do your job (add/edit/remove permissions on security objects (like
users/folders/files/printers) )
and it's usable from .NET too:

string _udir = rootFolder + folder;
ADsSecurity _adSec = new ADsSecurity();

IADsSecurityDescriptor _sd =
(IADsSecurityDescriptor)_adSec.GetSecurityDescript or("FILE://"+_udir );
IADsAccessControlList _dacl =
(IADsAccessControlList)_sd.DiscretionaryAcl;

_sd.Control =
(int)ActiveDs.ADS_SD_CONTROL_ENUM.ADS_SD_CONTROL_S E_DACL_PROTECTED;

ActiveDs.AccessControlEntry _ace3 = new ActiveDs.AccessControlEntry();
_ace3.Trustee = <YOUR_USER_NAME>;

//_ace3.Trustee="Internet Guest Account";
_ace3.AccessMask =
(int)ActiveDs.ADS_RIGHTS_ENUM.ADS_RIGHT_GENERIC_EX ECUTE
|(int)ActiveDs.ADS_RIGHTS_ENUM.ADS_RIGHT_GENERIC_R EAD
|(int)ActiveDs.ADS_RIGHTS_ENUM.ADS_RIGHT_READ_CONT ROL
|(int)ActiveDs.ADS_RIGHTS_ENUM.ADS_RIGHT_SYNCHRONI ZE
|(int)ActiveDs.ADS_RIGHTS_ENUM.ADS_RIGHT_GENERIC_W RITE
|(int)ActiveDs.ADS_RIGHTS_ENUM.ADS_RIGHT_GENERIC_E XECUTE;

_ace3.AceType =
(int)ActiveDs.ADS_ACETYPE_ENUM.ADS_ACETYPE_ACCESS_ ALLOWED;
_ace3.AceFlags =
(int)ActiveDs.ADS_ACEFLAG_ENUM.ADS_ACEFLAG_INHERIT _ACE|1;

_dacl.AddAce(_ace3);

//

_sd.DiscretionaryAcl = _dacl;
_adSec.SetSecurityDescriptor(_sd,"FILE://"+ _udir);

HTH,
Daniel

"Ram" <ni***@bezeqint.net> wrote in message
news:eb**************@tk2msftngp13.phx.gbl...
Hey,
I'v managed to find a way of adding NTFS permissions to a certain folder,
But the problem is, the folder has a couple of inherited permissions which I want to delete.
How can I remove the folder's NTFS permissions WITHOUT using WMI or special XP features?
Thanks ahead!

--Ram

Nov 16 '05 #2

P: n/a
Ram, my dilemna is somewhat the same. Please see "Converting Win32 API to VB.Net". I feel that the solution is easiest with the Win32 API, however I am not able to get it to work completely. Hence, the post for help on this site. Good luck!
Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.