AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Win32/Win64 API (native code) Delphi TreeResetNamedSecurityInfoW-Aufrufproblem
Thema durchsuchen
Ansicht
Themen-Optionen

TreeResetNamedSecurityInfoW-Aufrufproblem

Ein Thema von Ghostwalker · begonnen am 27. Feb 2007 · letzter Beitrag vom 9. Mär 2007
 
Ghostwalker

Registriert seit: 16. Jun 2003
Ort: Schönwald
1.299 Beiträge
 
Delphi 10.3 Rio
 
#16

Re: TreeResetNamedSecurityInfoW-Aufrufproblem

  Alt 9. Mär 2007, 10:03
Strike Problem gelöst.

Ursache war ein falsch gesetztes Flag bei den SecurityInformations. Der Fehler lag genau in der Routine MakeControlBits, und dieser Fehler ist auch in meiner C++-Vorlage.

Jetzt sieht die Routine wie folgt aus:

Delphi-Quellcode:
  procedure MakeControlBits;
  begin
    aclPresent := False;
    aclDefault := False;
    SDRevision := 0;
    psd := 0;
    if not (GetSecurityDescriptorControl(pSecurityDescriptor, psd, SDRevision)) then
      DoError(GetLastError);
    if ((SecurityInformation and DACL_SECURITY_INFORMATION) = DACL_SECURITY_INFORMATION) then
    begin
      if ((psd and SE_DACL_PROTECTED) = SE_DACL_PROTECTED) then
      begin
        SecurityInformation := SecurityInformation or PROTECTED_DACL_SECURITY_INFORMATION;
        if not (SetSecurityDescriptorControl(NewSecurityDescriptor, SE_DACL_PROTECTED, SE_DACL_PROTECTED)) then
          DoError(GetLastError);
      end
      else
      begin
        if ((psd and SE_DACL_AUTO_INHERIT_REQ) = SE_DACL_AUTO_INHERIT_REQ) then
        begin
          SecurityInformation := SecurityInformation or UNPROTECTED_DACL_SECURITY_INFORMATION;
          if not (SetSecurityDescriptorControl(NewSecurityDescriptor, SE_DACL_AUTO_INHERIT_REQ, SE_DACL_AUTO_INHERIT_REQ)) then
            DoError(GetLastError);
        end;
      end;
    end;
    if ((SecurityInformation and SACL_SECURITY_INFORMATION) = SACL_SECURITY_INFORMATION) then
    begin
      if ((psd and SE_SACL_PROTECTED) = SE_SACL_PROTECTED) then
      begin
        SecurityInformation := SecurityInformation or PROTECTED_SACL_SECURITY_INFORMATION;
        if not (SetSecurityDescriptorControl(NewSecurityDescriptor, SE_SACL_PROTECTED, SE_SACL_PROTECTED)) then
          DoError(GetLastError);
      end
      else
      begin
        if ((psd and SE_SACL_AUTO_INHERIT_REQ) = SE_SACL_AUTO_INHERIT_REQ) then
        begin
          SecurityInformation := SecurityInformation or UNPROTECTED_SACL_SECURITY_INFORMATION;
          if not (SetSecurityDescriptorControl(NewSecurityDescriptor, SE_SACL_AUTO_INHERIT_REQ, SE_SACL_AUTO_INHERIT_REQ)) then
            DoError(GetLastError);
        end;
      end;
    end;
  end;
Zur Optimierung hab ich NewSI noch rausgeschmissen und dafür SecurityInformation vor dem Aufruf
noch korregiert:

Delphi-Quellcode:
      SecurityInformation := SecurityInformation and not (SI_OWNER_RECURSE or SI_RESET_DACL_TREE or SI_RESET_SACL_TREE);
      dErr := TreeResetNamedSecurityInfoW(pwidechar(ffilename),
        SE_FILE_OBJECT,
        SecurityInformation,
        NewOwner,
        NewGroup,
        NewDACL,
        NewSACL,
        True,
        @DoTreeProgress,
        ProgressInvokeEveryObject,
        SELF);
Jetzt funktioniert das ganze. Sogar die Callback-Routine wird aufgerufen.

Danke an alle die hier mitgeholfen haben.

Thanks to all they helped here
Uwe
e=mc² or energy = milk * coffee²
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 15:50 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz