How to change the file ACL in windows, if I only know the SID?

倾然丶 夕夏残阳落幕 提交于 2019-12-11 07:44:30

问题


I want to change the ACL of a file and set "full permissions" to a special user.

I know the cacls-command cacls . /e /t /p Everyone:f

But this only works if the OS is english. For german systems, it must be cacls . /e /t /p Jeder:f.

I know the well-known SIDs of the user "everyone" (S-1-1-0), but it seems as if I can't use them with cacls.

I tried cacls . /e /t /p S-1-1-0:f.

Is there a way to use windows command line tools for this jobs? I'm not allowed to bundle software or other commandline tools for this job with my software.

The solution has to be called from a Java-Process, but that should not be a problem.


回答1:


This might be Windows version specific, but look at

 whoami /groups

and parse the result. On Windows 7, this

 whoami /groups | find "S-1-1-0"

looks like this for me

C:\>whoami /groups | find "S-1-1-0"
Everyone                                  Well-known group S-1-1-0
                     Mandatory group, Enabled by default, Enabled group

There's a whole Win32 API for getting at this. Here's a solution using that from C#

http://www.ms-news.net/f2438/setpermission-everyone-c-4997971.html




回答2:


I found a solution. I am using a library from the vendor of my Setup creation tool.

edit:

Solution for problem:

The Setup-Creation Tool Install4j has a method getUserLogin(String sid) its returnvalue is something like: WORKSTATION1\User1

I used cacls to change the ACL.



来源:https://stackoverflow.com/questions/4389868/how-to-change-the-file-acl-in-windows-if-i-only-know-the-sid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!