Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Security > question

Thread Tools question

Darko Bazulj
Posts: n/a

how to clear DACL from folder/file?

I want to achive next:

I want to clear DACL and add ACEs to ACL and 'stop inheritance'(this work).
But when I do that "Everyone" ACEs are added to ACL so I need to remove
"Everyone" ACE from ACL.

I now do next but is there maybe some better way?

To remove 'Everyone' I use 'RemoveAccessRuleAll'.


Sub Main()

SetInheritance("C:\tmp\ntfs\test", True, False)

End Sub

Sub ClearDACL(ByVal strFolderName As String)

Dim dInfo As New DirectoryInfo(strFolderName)
Dim dSecurity As DirectorySecurity =

dSecurity.AddAccessRule(New FileSystemAccessRule("Everyone",
FileSystemRights.Read, AccessControlType.Allow))


End Sub

Sub SetInheritance(ByVal strFolderPath As String, ByVal isProtected As
Boolean, ByVal preserveInheritance As Boolean)

Dim dInfo As New DirectoryInfo(strFolderPath)
Dim dSecurity As DirectorySecurity = dInfo.GetAccessControl()

dSecurity.SetAccessRuleProtection(isProtected, preserveInheritance)

End Sub


Darko Bazulj

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
question row filter (more of sql query question) =?Utf-8?B?YW5kcmV3MDA3?= ASP .Net 2 10-06-2005 01:07 PM
Quick Question - Newby Question =?Utf-8?B?UnlhbiBTbWl0aA==?= ASP .Net 4 02-16-2005 11:59 AM
Question on Transcender Question :-) eddiec MCSE 6 05-20-2004 06:59 AM
Question re: features of the 831 router (also a 924 question) Wayne Cisco 0 03-02-2004 07:57 PM
Syntax Question - Novice Question sean ASP .Net 1 10-20-2003 12:18 PM