Microsoft Developer Network > 포럼 홈 > Visual Basic General > FileSystemAccessRule: everyone group
질문하기질문하기
 

제안된 답변FileSystemAccessRule: everyone group

  • 2007년 5월 29일 화요일 오후 3:46vistapolar 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     

    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:

    Dim dirSec As New DirectorySecurity

    dirSec = Directory.GetAccessControl(dirPath)

    dirSec.AddAccessRule(New FileSystemAccessRule("Everyone", FileSystemRights.FullControl, InheritanceFlags.ContainerInherit Or InheritanceFlags.ObjectInherit, PropagationFlags.InheritOnly, AccessControlType.Allow))

    Directory.SetAccessControl(dirPath, dirSec)

     

    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 "Everyone" with "Jeder". Is it possible to call a method that permits to generalize the code for every language of the operating system?

     

    Thanks in advance

모든 응답

  • 2007년 6월 15일 금요일 오전 12:00TheArcticOwl 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     

     Hello !

    Use SID strings instead of  symbolic names like "Everyone", "BUILTIN\Users" etc.

    For "Everyone"     SID = "S-1-1-0".  You can look it (and other well known SIDs)   up in WinNT.h.

      AddAccessRule("S-1-1-0", ...,..);

    Also - here is a link to a helpful article --  http://support/microsoft.com/kb/243330.

    gl

  • 2008년 1월 18일 금요일 오후 1:50satankidneypie 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     제안된 답변
    This will give you the "Everyone" string that you require for each version of the OS e.g. English, German etc.              

    System.Security.Principal.SecurityIdentifier sid = new System.Security.Principal.SecurityIdentifier(System.Security.Principal.WellKnownSidType.WorldSid, null);
    System.Security.Principal.NTAccount acct = sid.Translate(typeof(System.Security.Principal.NTAccount)) as System.Security.Principal.NTAccount ;
    string strEveryoneAccount = acct.ToString();

    try
    {
    System.Security.AccessControl.FileSecurity sec = System.IO.File.GetAccessControl(FILENAME);
    sec.AddAccessRule(new System.Security.AccessControl.FileSystemAccessRule(
    strEveryoneAccount,
    System.Security.AccessControl.FileSystemRights.FullControl,
    System.Security.AccessControl.AccessControlType.Allow));
    File.SetAccessControl(FILENAME, sec);
    }
    catch(UnauthorizedAccessException)
    {
    // handle permissions problem
    }
    • 답변으로 제안됨crashSmoke 2009년 3월 19일 목요일 오후 1:52
    •  
  • 2008년 11월 6일 목요일 오후 1:12commoduss 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     코드 있음

    thank you satankidneypie you saved my life

  • 2009년 3월 9일 월요일 오후 6:53Steve_K 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    I am having trouble to get the below translated to VB.NET ... can someone help? TIA!


    System.Security.Principal.SecurityIdentifier sid = new System.Security.Principal.SecurityIdentifier(System.Security.Principal.WellKnownSidType.WorldSid, null);
    System.Security.Principal.NTAccount acct = sid.Translate(typeof(System.Security.Principal.NTAccount)) as System.Security.Principal.NTAccount ;
    string strEveryoneAccount = acct.ToString();

  • 2009년 3월 10일 화요일 오전 7:47Steve_K 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    Nevermind ... got it:

            Dim sid As New System.Security.Principal.SecurityIdentifier(System.Security.Principal.WellKnownSidType.WorldSid, Nothing)
            Dim acct As System.Security.Principal.NTAccount = TryCast(sid.Translate(GetType(System.Security.Principal.NTAccount)), System.Security.Principal.NTAccount)
            Dim strEveryoneAccount As String = acct.ToString()
  • 2009년 3월 19일 목요일 오후 1:52crashSmoke 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    Awesomely helpful - thanks dude!!
    354 Errors.... must have missed a semi-colon somewhere