FileSystemAccessRule: everyone group<p>I am developping an installer class and I want to set specific permissions for all users. I know that this is possible with a code like this:</p> <p><font color="#0000ff" size=2></font></p> <p>Dim<font size=2> dirSec </font><font color="#0000ff" size=2>As</font><font size=2> </font><font color="#0000ff" size=2>New</font><font size=2> DirectorySecurity</p> <p>dirSec = Directory.GetAccessControl(dirPath)</p><font size=2> <p>dirSec.AddAccessRule(</font><font color="#0000ff" size=2>New</font><font size=2> FileSystemAccessRule(</font><font color="#800000" size=2>&quot;Everyone&quot;</font><font size=2>, FileSystemRights.FullControl, InheritanceFlags.ContainerInherit </font><font color="#0000ff" size=2>Or</font><font size=2> InheritanceFlags.ObjectInherit, PropagationFlags.InheritOnly, AccessControlType.Allow))</p></font><font size=2> <p>Directory.SetAccessControl(dirPath, dirSec)</p> <p></font></font> </p> <p>Unhopefully I need this code to be valid for computers with different InstalledUICulture. For instance I know that in German it is sufficient to replace &quot;Everyone&quot; with &quot;Jeder&quot;. Is it possible to call a method that permits to generalize the code for every language of the operating system?</p> <p> </p> <p>Thanks in advance</p>© 2009 Microsoft Corporation. All rights reserved.Thu, 19 Mar 2009 13:52:50 Zdc841874-b71b-4e1c-9052-06eb4a87d08fhttp://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/dc841874-b71b-4e1c-9052-06eb4a87d08f#dc841874-b71b-4e1c-9052-06eb4a87d08fhttp://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/dc841874-b71b-4e1c-9052-06eb4a87d08f#dc841874-b71b-4e1c-9052-06eb4a87d08fvistapolarhttp://social.msdn.microsoft.com/Profile/en-US/?user=vistapolarFileSystemAccessRule: everyone group<p>I am developping an installer class and I want to set specific permissions for all users. I know that this is possible with a code like this:</p> <p><font color="#0000ff" size=2></font></p> <p>Dim<font size=2> dirSec </font><font color="#0000ff" size=2>As</font><font size=2> </font><font color="#0000ff" size=2>New</font><font size=2> DirectorySecurity</p> <p>dirSec = Directory.GetAccessControl(dirPath)</p><font size=2> <p>dirSec.AddAccessRule(</font><font color="#0000ff" size=2>New</font><font size=2> FileSystemAccessRule(</font><font color="#800000" size=2>&quot;Everyone&quot;</font><font size=2>, FileSystemRights.FullControl, InheritanceFlags.ContainerInherit </font><font color="#0000ff" size=2>Or</font><font size=2> InheritanceFlags.ObjectInherit, PropagationFlags.InheritOnly, AccessControlType.Allow))</p></font><font size=2> <p>Directory.SetAccessControl(dirPath, dirSec)</p> <p></font></font> </p> <p>Unhopefully I need this code to be valid for computers with different InstalledUICulture. For instance I know that in German it is sufficient to replace &quot;Everyone&quot; with &quot;Jeder&quot;. Is it possible to call a method that permits to generalize the code for every language of the operating system?</p> <p> </p> <p>Thanks in advance</p>Tue, 29 May 2007 15:46:50 Z2007-05-29T15:46:50Zhttp://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/dc841874-b71b-4e1c-9052-06eb4a87d08f#1483a22f-dd70-4c45-93f3-928815ec932ehttp://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/dc841874-b71b-4e1c-9052-06eb4a87d08f#1483a22f-dd70-4c45-93f3-928815ec932eTheArcticOwlhttp://social.msdn.microsoft.com/Profile/en-US/?user=TheArcticOwlFileSystemAccessRule: everyone group<p> Hello !</p> <p>Use SID strings instead of  symbolic names like &quot;Everyone&quot;, &quot;BUILTIN\Users&quot; etc.</p> <p>For &quot;Everyone&quot;     SID = &quot;S-1-1-0&quot;.  You can look it (and other well known SIDs)   up in WinNT.h.</p> <p>  AddAccessRule(&quot;S-1-1-0&quot;, ...,..);</p> <p>Also - here is a link to a helpful article --  <a title="http://support/microsoft.com/kb/243330" href="http://support/microsoft.com/kb/243330">http://support/microsoft.com/kb/243330</a>.</p> <p>gl</p>Fri, 15 Jun 2007 00:00:48 Z2007-06-15T00:00:48Zhttp://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/dc841874-b71b-4e1c-9052-06eb4a87d08f#02e87596-846d-44a2-9434-b7463ea55254http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/dc841874-b71b-4e1c-9052-06eb4a87d08f#02e87596-846d-44a2-9434-b7463ea55254satankidneypiehttp://social.msdn.microsoft.com/Profile/en-US/?user=satankidneypieFileSystemAccessRule: everyone groupThis will give you the &quot;Everyone&quot; string that you require for each version of the OS e.g. English, German etc.               <br><br>System.Security.Principal.SecurityIdentifier sid = new System.Security.Principal.SecurityIdentifier(System.Security.Principal.WellKnownSidType.WorldSid, null);<br>System.Security.Principal.NTAccount acct = sid.Translate(typeof(System.Security.Principal.NTAccount)) as System.Security.Principal.NTAccount ;<br>string strEveryoneAccount = acct.ToString();<br><br>try<br>{<br> <div style="margin-left:40px">System.Security.AccessControl.FileSecurity sec = System.IO.File.GetAccessControl(FILENAME);<br></div> <div style="margin-left:40px">sec.AddAccessRule(new System.Security.AccessControl.FileSystemAccessRule(<br></div> <div style="margin-left:80px">strEveryoneAccount,<br></div> <div style="margin-left:80px">System.Security.AccessControl.FileSystemRights.FullControl,<br></div> <div style="margin-left:80px">System.Security.AccessControl.AccessControlType.Allow));<br></div> <div style="margin-left:40px">File.SetAccessControl(FILENAME, sec);<br></div>}<br>catch(UnauthorizedAccessException)<br>{<br> <div style="margin-left:40px">// handle permissions problem<br></div>}<br>Fri, 18 Jan 2008 13:50:16 Z2008-01-18T13:50:16Zhttp://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/dc841874-b71b-4e1c-9052-06eb4a87d08f#831b4fc6-02ba-46bf-9fdf-a1d0df09b9c3http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/dc841874-b71b-4e1c-9052-06eb4a87d08f#831b4fc6-02ba-46bf-9fdf-a1d0df09b9c3commodusshttp://social.msdn.microsoft.com/Profile/en-US/?user=commodussFileSystemAccessRule: everyone group<p>thank you satankidneypie you saved my life</p>Thu, 06 Nov 2008 13:12:54 Z2008-11-06T13:12:54Zhttp://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/dc841874-b71b-4e1c-9052-06eb4a87d08f#9fcd150f-1a80-4ac2-868f-c9a0b3ca5605http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/dc841874-b71b-4e1c-9052-06eb4a87d08f#9fcd150f-1a80-4ac2-868f-c9a0b3ca5605Steve_Khttp://social.msdn.microsoft.com/Profile/en-US/?user=Steve_KFileSystemAccessRule: everyone groupI am having trouble to get the below translated to VB.NET ... can someone help? TIA!<br><br> <br> <b>System.Security.Principal.SecurityIdentifier sid = new System.Security.Principal.SecurityIdentifier(System.Security.Principal.WellKnownSidType.WorldSid, null);<br> System.Security.Principal.NTAccount acct = sid.Translate(typeof(System.Security.Principal.NTAccount)) as System.Security.Principal.NTAccount ;<br> string strEveryoneAccount = acct.ToString();</b><br> Mon, 09 Mar 2009 18:53:41 Z2009-03-09T18:53:41Zhttp://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/dc841874-b71b-4e1c-9052-06eb4a87d08f#2901f50e-48c0-4c02-885d-b7169c92627dhttp://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/dc841874-b71b-4e1c-9052-06eb4a87d08f#2901f50e-48c0-4c02-885d-b7169c92627dSteve_Khttp://social.msdn.microsoft.com/Profile/en-US/?user=Steve_KFileSystemAccessRule: everyone groupNevermind ... got it:<br><br>        Dim sid As New System.Security.Principal.SecurityIdentifier(System.Security.Principal.WellKnownSidType.WorldSid, Nothing)<br>        Dim acct As System.Security.Principal.NTAccount = TryCast(sid.Translate(GetType(System.Security.Principal.NTAccount)), System.Security.Principal.NTAccount)<br>        Dim strEveryoneAccount As String = acct.ToString()<br> Tue, 10 Mar 2009 07:47:27 Z2009-03-10T07:47:27Zhttp://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/dc841874-b71b-4e1c-9052-06eb4a87d08f#6dd6a4da-bc6a-4496-b61d-c3f468ff447chttp://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/dc841874-b71b-4e1c-9052-06eb4a87d08f#6dd6a4da-bc6a-4496-b61d-c3f468ff447ccrashSmokehttp://social.msdn.microsoft.com/Profile/en-US/?user=crashSmokeFileSystemAccessRule: everyone groupAwesomely helpful - thanks dude!! <hr class="sig">354 Errors.... must have missed a semi-colon somewhereThu, 19 Mar 2009 13:52:29 Z2009-03-19T13:52:29Z