Hi Torsten,

There are a number of options:

1) You can modify the ACL using WMI in the System.Management namespace
2) Use p/Invoke directly
3) There's a component that comes with the ADSI SDK (adssecurity.dll)

On the WMI route, there are some samples available in MSDN and some good
postings on the subject if you search groups.google.com.  I recommend
looking for GetSecurityDescriptor - that's the function you'll need to
call to change the ACLs.  There's quite a long thread on
microsoft.public.dotnet.languages.csharp with some great info.

It takes a while to write the code, and a lot of testing.  I've seen
some strange behaviour that I haven't been able to determine the source
of.

If you can, I would try and avoid dynamically changing the ACLs.  Can
you setup a special directory that already have full control, and write
your file there?  Unless you're application is somehow changing the
permissions dynamically, this is a much easier route.

Jeff

-----Original Message-----
From: Torsten Kramer [mailto:[EMAIL PROTECTED]] 
Sent: May 06, 2002 6:10 AM
To: [EMAIL PROTECTED]
Subject: Modify ACL from .NET

Hi!

Does anyone know how to modify the Access Control List (ACL) of a NTFS
file or directory under .NET? I want to create a file and then give the
Users group the Full Control permission for the file.

Thanks,

Torsten

You can read messages from the DOTNET archive, unsubscribe from DOTNET,
or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to