C# - How do I get the "Everybody" user?

fpdragon picture fpdragon · Feb 16, 2011 · Viewed 10.2k times · Source

I already wrote a code which can create a share and change permissions for the current user. The goal was to always allow all for everybody on share level and deny rights on ntfs acl level.

I use a german windows and I noticed that I only can access the everybody user by using "jeder". In english it would be the user "everybody" or "all" I think?! Anyway I'm searching for a way to get the name of the everybody user language independent.

Hope this is possible.

Answer

Mark Cidade picture Mark Cidade · Feb 16, 2011

The name that the English version of Windows uses is "Everyone".

You can get the user regardless of language by using the WellKnownSidType.WorldSid value:

var sid = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
var account = (NTAccount) sid.Translate(typeof(NTAccount));