Home All Groups Group Topic Archive Search About
Author
25 Jul 2006 2:56 AM
Colin Halliday
Can anyone point in the direction of a good reference, using VB.Net, for
working with directory security?

My code has located a directory that has inherited access rights form a
parent directory.  I want to programmatically turn off the inheritance from
above, completely remove all existing access rights and then replace them
with a new set of access rights for various accounts.  I want these new
rights to be inherited downwards to all child directories and files.

Any help is appreciated.

--
Colin Halliday

Author
1 Aug 2006 7:48 AM
Arjan van den Noort
Hi Colin,
I had the same question did it like this:

'  Imports System.Security.AccessControl
Dim security As New DirectorySecurity
'  protect the rules from inheriting the parent's security settings
security.SetAccessRuleProtection(True, False)   '  turn of ineritance, do
not keep current settings
'  Persist the changes
System.IO.Directory.SetAccessControl("D:\test\testdir", security)

As far as i know .NET Framework version 2.0 is needed.
This article was helpfull for me:
http://msdn.microsoft.com/msdnmag/issues/04/11/AccessControlinNET/

Regards,
Arjan


Show quoteHide quote
"Colin Halliday" <kothesit@newsgroup.nospam> wrote in message
news:ed6OtY5rGHA.356@TK2MSFTNGP05.phx.gbl...
> Can anyone point in the direction of a good reference, using VB.Net, for
> working with directory security?
>
> My code has located a directory that has inherited access rights form a
> parent directory.  I want to programmatically turn off the inheritance
> from above, completely remove all existing access rights and then replace
> them with a new set of access rights for various accounts.  I want these
> new rights to be inherited downwards to all child directories and files.
>
> Any help is appreciated.
>
> --
> Colin Halliday
>