Groups | Blog | Home
all groups > dotnet security > march 2005 >

dotnet security : Changing folder security



Nicole Calinoiu
3/30/2005 10:17:04 AM
This functionality is not available in the v. 1.x .NET Framework. You could
either call the relevant Windows API functions yourself via p/invoke or use
a wrapper API like the one available at
http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=e6098575-dda0-48b8-9abf-e0705af065d9.

HTH,
Nicole



[quoted text, click to view]

Nicole Calinoiu
3/30/2005 11:53:10 AM
There are many Windows API functions that you will need to call in order to
set the ACL on a file. Even if you don't want to use the library available
at
http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=e6098575-dda0-48b8-9abf-e0705af065d9,
you could download it and examine its API usage in order to figure out how
this is done.



[quoted text, click to view]

Feldman Alex
3/30/2005 4:12:11 PM
Hi all!
I need to set folder security to full control to everyone
is it possible from code (without calling any external applications and
sripts) ?
example would be nice.

Thanx

Feldman Alex
3/30/2005 6:19:37 PM
Thanks Nicole

Maybe you know which Windows API should i use

Thanks again
[quoted text, click to view]

Joseph MCAD
3/31/2005 8:33:06 AM

March 31, 2005

It is not provided in .Net 1.* directly, but it is very easy to do with
a different class. You just have to use the command line from code. (By the
way, it is supported in 2.0)

Imports System.Diagnostics

dim Pro as new Process
Pro.StartInfo.Filename = "xcacls"
Pro.StartInfo.Arguments = "FOLDERPATH /G Everyone:F /Y
'Set so that no window appears while running
Pro.StartInfo.UseExecuteShell = false
Pro.StartInfo.CreateNoWindow = true
'Redirect output to the process class for futher examination
Pro.StartInfo.RedirectStandardOutput = true

Pro.Start
dim reader as streamreader = Pro.StandartOutput
dim output as string = reader.readtoend

Pro.WaitForExit()
reader.close
messagebox.show(output)

This will show the output generated from xcacls in a messagebox. I hope
this helps and have a great day! (This is how you can use command line
programs from code.)


Joseph MCAD


[quoted text, click to view]
Feldman Alex
3/31/2005 11:21:40 AM
Thanx a lot Nicole

[quoted text, click to view]

AddThis Social Bookmark Button