Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8161907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:35:52+00:00 2026-06-06T18:35:52+00:00

Just now I’m looking at fixing a localization bug with a small application that

  • 0

Just now I’m looking at fixing a localization bug with a small application that get’s fired during the install of a software package. The small application essentially brute forces permissions on our own folder within Application Data to set EVERYONE to full access.

The problem arises with EVERYONE not being localized. I know I need to use SID’s, which for EVERYONE, is S-1-1-0. I can’t find a WinAPI function for setting permissions using an SID.

The function just now uses BuildExplicitAccessWithName and SetNamedSecurityInfo as shown below

function setfullaccess(foldername:string):boolean;    //B2415 MDE
var
 pDACL: PACL;
 pEA: PEXPLICIT_ACCESS_A;
 R: DWORD;
begin
 result := true;
 pEA := AllocMem(SizeOf(EXPLICIT_ACCESS));
 BuildExplicitAccessWithName(pEA, 'EVERYONE', GENERIC_ALL{GENERIC_READ},GRANT_ACCESS, SUB_CONTAINERS_AND_OBJECTS_INHERIT{NO_INHERITANCE});
 R := SetEntriesInAcl(1, pEA, nil, pDACL);
 if R = ERROR_SUCCESS then
 begin
  if SetNamedSecurityInfo(pchar(foldername), SE_FILE_OBJECT,DACL_SECURITY_INFORMATION, nil, nil, pDACL, nil) <> ERROR_SUCCESS then result := false;
  LocalFree(Cardinal(pDACL));
 end
 else result := false;//ShowMessage('SetEntriesInAcl failed: ' + SysErrorMessage(R));
end;

Which functions should I be looking at using instead?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T18:35:54+00:00Added an answer on June 6, 2026 at 6:35 pm

    After some searching through the WinAPI documentation I went for the solution below. Essentially I use the SID to lookup the “readable” name and then use that. It won’t be the most elegant solution but it works for me.

    procedure TTestform.Button4Click(Sender: TObject);
    var
     Sid: PSID;
     peUse: DWORD;
     cchDomain: DWORD;
     cchName: DWORD;
     Name: array of Char;
     Domain: array of Char;
     pDACL: PACL;
     pEA: PEXPLICIT_ACCESS_A;
     R: DWORD;
     foldername: String; //Temp to hardcode
    begin
     foldername := 'C:\TEMP'; //Temp to hardcode
     Sid := nil;
     Win32Check(ConvertStringSidToSidA(PChar('S-1-1-0'), Sid));
     cchName := 0;
     cchDomain := 0;
     //Get Length
     if (not LookupAccountSid(nil, Sid, nil, cchName, nil, cchDomain, peUse)) and (GetLastError = ERROR_INSUFFICIENT_BUFFER) then
     begin
      SetLength(Name, cchName);
      SetLength(Domain, cchDomain);
      if LookupAccountSid(nil, Sid, @Name[0], cchName, @Domain[0], cchDomain, peUse) then
      begin
       pEA := AllocMem(SizeOf(EXPLICIT_ACCESS));
       BuildExplicitAccessWithName(pEA, PChar(Name), GENERIC_ALL{GENERIC_READ},GRANT_ACCESS, SUB_CONTAINERS_AND_OBJECTS_INHERIT{NO_INHERITANCE});
       R := SetEntriesInAcl(1, pEA, nil, pDACL);
       if R = ERROR_SUCCESS then
       begin
        if SetNamedSecurityInfo(pchar(foldername), SE_FILE_OBJECT,DACL_SECURITY_INFORMATION, nil, nil, pDACL, nil) <> ERROR_SUCCESS then ShowMessage('SetNamedSecurityInfo failed: ' + SysErrorMessage(GetLastError));
        LocalFree(Cardinal(pDACL));
       end
       else ShowMessage('SetEntriesInAcl failed: ' + SysErrorMessage(R));
      end;
     end;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just now I was looking for a regex that will detect string not enclosed
I'm just now starting to build so that you get an email to him,
Working in Delphi7 just now, I noticed that not only a VarIsEmpty function exists,
I was looking through a code tutorial just now, and found something interesting --
I'm writing a little app that displays some graphics and just now I'm trying
Just now I found that static libraries in *nix systems, in other words *.a
I'm just now starting to get into the idea of threading, and wanted to
I've just now started reading an Algorithms book that defined Graphs as follows: Graphs
Just now I came across ApplicationSettings in .NET WinForms that could handle complex types.
I bumped into something unexpected just now, and it reminded me that there is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.