user844541
user844541

Reputation: 2958

Everyone's sid in Windows 8

I am developing a .net 3.5 application that should run on both windows 8 and 7.

As part of the application I am creating a new folder under C:\ProgramData.

After creating the folder I set the following ACL - Allow everyone to read and write.

 var directorySecurity = directoryInfo.GetAccessControl();
 var worldSecurityIdentifier = new SecurityIdentifier(WellKnownSidType.WorldSid, null);     
 directorySecurity.AddAccessRule(new FileSystemAccessRule(worldSecurityIdentifier, FileSystemRights.Read, AccessControlType.Allow));
 directorySecurity.AddAccessRule(new FileSystemAccessRule(worldSecurityIdentifier, FileSystemRights.Write, AccessControlType.Allow));

On Windows 8 I encounter the following behavior: if I copy a file to that directory, when I look at the security tab in the file's properties, this is what I see.

Security tab of a file that was copied into the directory

I don't understand who is this user and how it was created. and also where is the ACL that I defined for everyone?

It seems that this unknown SID got the ACLs that I had set for Everyone.

I suspected that maybe this is because I am developing on .net 3.5 instead of 4, but when I changed the target framework to 4 it didn't help.

When I check in debug what is the worldSecurityIdentifier, this is what I get

enter image description here

Can anyone help me figure this out?

Upvotes: 3

Views: 545

Answers (1)

mjk
mjk

Reputation: 541

Try:

directorySecurity.AddAccessRule(
   new FileSystemAccessRule(
       worldSecurityIdentifier,
       FileSystemRights.Read | FileSystemRights.Write,
       InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
       PropagationFlags.None,
       AccessControlType.Allow));

This will set the ACE so it is Inherited by child objects.

Upvotes: 3

Related Questions