FileSecurity - Allow full access for everyone to a folder

delphi package - easy access to security apis
Post Reply
fpj
Posts: 5
Joined: Tue May 26, 2015 5:52 pm

FileSecurity - Allow full access for everyone to a folder

Post by fpj »

Hello Madshi! How are you? I am an old (registered) user and a fan of you and your solutions.

Please give me a little help. I am using madSecurity FileSecurity to allow full access for "everyone" to a specific folder:

Code: Select all

with FileSecurity('c:\test').DAcl do
begin
  Clear;
  SetFileAccess(Everyone, true);
  Flush;
end;
Am I doing the right way? I see some people using "Deallocate" instead of "SetFileAccess(Everyone, true)", what is the difference?

Thank you!

Fabio
madshi
Site Admin
Posts: 10749
Joined: Sun Mar 21, 2004 5:25 pm

Re: FileSecurity - Allow full access for everyone to a folde

Post by madshi »

You don't necessarily need to use "Flush", it should be done automatically, but only when the FileSecurity interface runs out of scope. The "Flush" shouldn't harm, though, so you can keep it there.

A "NULL" ACL by default gives access to Everyone. So simply doing Deallocate will have the same effect. Actually, it's different: Deallocate will truely assign a NULL ACL, which Windows interprets as full access for Everyone. Your code instead assigns a valid ACL which has the user "Everyone" in it. Different things to achieve the same effective OS behaviour.
fpj
Posts: 5
Joined: Tue May 26, 2015 5:52 pm

Re: FileSecurity - Allow full access for everyone to a folde

Post by fpj »

Ok, understood! Thank you again! Success!
Post Reply