开发者

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

I want to change the ACL of a file and set "full permissions" t开发者_开发技巧o 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.


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


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜