开发者

C# - How can I duplicate this "Access denied" to folder / file behavior

I have a program, "Folder Protect". It locks folders, make them invisible, impossible to delete, impossible to write things to. I would like to duplicate the program behavior for the locking folder.

Here's some images of the folder locking: the alert it gives after locking a folder and trying to access it: http://img841.imageshack.us/i/pic1yo.png/

images of the security tab before locking:

http://img9.imageshack.us/i/sectabbeforelock.png/

http://img256.imageshack.us/i/advbeforelock.png/

http://img403.imageshack.us/i/ownertabbeforelock.png/

Images of the security tab after locking:

http://img62.imageshack.us/i/sectabafterlock.png/

http://img826.imageshack.us/i/advafterlock.png/

http://img573.imageshack.us/i/ownertabafterlock.png/

What the program does:

the program removes any permissions and also changes the ownership - without the possibility that the user will change ownership

as you can see in the owner tab: "Unable to display current owner."

trying to change owner will result in: "Windows Security - Unable to set new owner on New Folder. Access is denied."

I tried to use the "subinacl" tool to check if it is possible to change the f开发者_如何学Pythonolder owner and it gives me the following error when trying to display the ownership or change it: "CreateFile error: 5"

Is it possible to duplicate this behavior? Thanks in advanced.


It will definitely be possible - but it might require some PInvoke calls.

For starting you off in the right direction, here are some articles:

  • Here's quite an old article on ACL using Microsoft.Win32.Security - http://weblogs.asp.net/cumpsd/archive/2004/02/08/69403.aspx
  • Microsoft's advice on ACL using ActiveDirectory in C# - http://support.microsoft.com/kb/899553

Hope these help

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜