var
FiName :
String;
psd : PSECURITY_DESCRIPTOR;
dwLen : DWORD;
psdc : SECURITY_DESCRIPTOR_CONTROL;
dwDummy : DWORD;
lpbDaclPresent : Bool;
lpbDaclDefaulted : Bool;
pDacl : PACL;
lpbSaclPresent : Bool;
lpbSaclDefaulted : Bool;
pSacl : PACL;
begin
Result := False;
// if not OpenDialog1.Execute then exit;
FiName := Edit1.Text + #0;
// erforderliche Buffergrösse ermitteln
dwLen := 0;
psd :=
nil;
GetFileSecurity(PChar(FiName),OWNER_SECURITY_INFORMATION,psd,0,dwLen);
// Security Descriptor auslesen
psd := AllocMem(dwLen);
try
if not GetFileSecurity(PChar(OpenDialog1.FileName),OWNER_SECURITY_INFORMATION,psd,dwLen,dwLen)
then begin
ShowMessage(SysErrorMessage(GetLastError));
exit;
end;
GetSecurityDescriptorControl(psd,psdc,dwDummy);
Memo1.Lines.Clear;
if (psdc
and SE_DACL_AUTO_INHERITED) = SE_DACL_AUTO_INHERITED
then Memo1.Lines.Add('
SE_DACL_AUTO_INHERITED');
if (psdc
and SE_DACL_DEFAULTED) = SE_DACL_DEFAULTED
then Memo1.Lines.Add('
SE_DACL_DEFAULTED');
if (psdc
and SE_DACL_PRESENT) = SE_DACL_PRESENT
then Memo1.Lines.Add('
SE_DACL_PRESENT');
if (psdc
and SE_DACL_PROTECTED) = SE_DACL_PROTECTED
then Memo1.Lines.Add('
SE_DACL_PROTECTED');
if (psdc
and SE_GROUP_DEFAULTED) = SE_GROUP_DEFAULTED
then Memo1.Lines.Add('
SE_GROUP_DEFAULTED');
if (psdc
and SE_OWNER_DEFAULTED) = SE_OWNER_DEFAULTED
then Memo1.Lines.Add('
SE_OWNER_DEFAULTED');
if (psdc
and SE_SACL_AUTO_INHERITED) = SE_SACL_AUTO_INHERITED
then Memo1.Lines.Add('
SE_SACL_AUTO_INHERITED');
if (psdc
and SE_SACL_DEFAULTED) = SE_SACL_DEFAULTED
then Memo1.Lines.Add('
SE_SACL_DEFAULTED');
if (psdc
and SE_SACL_PRESENT) = SE_SACL_PRESENT
then Memo1.Lines.Add('
SE_SACL_PRESENT');
if (psdc
and SE_SACL_PROTECTED) = SE_SACL_PROTECTED
then Memo1.Lines.Add('
SE_SACL_PROTECTED');
if (psdc
and SE_SELF_RELATIVE) = SE_SELF_RELATIVE
then Memo1.Lines.Add('
SE_SELF_RELATIVE');
pDacl :=
nil;
GetSecurityDescriptorDacl(psd, lpbDaclPresent, pDacl, lpbDaclDefaulted);
IF lpbDaclPresent
then begin
Memo1.lines.add('
DACL-ACL-Count: ' + inttostr(pDacl^.AceCount));
Memo1.lines.add('
DACL-ACL-Size: ' + inttostr(pDacl^.AclSize));
end else begin
Memo1.Lines.Add('
security descriptor does not contain a discretionary ACL for DACL');
end;
pSacl :=
nil;
GetSecurityDescriptorSacl(psd, lpbSaclPresent, pSacl, lpbSaclDefaulted);
IF lpbSaclPresent
then begin
Memo1.lines.add('
SACL-ACL-Count: ' + inttostr(pSacl^.AceCount));
Memo1.lines.add('
SACL-ACL-Size: ' + inttostr(pSacl^.AclSize));
end else begin
Memo1.Lines.Add('
security descriptor does not contain a discretionary ACL for SACL');
end;
Result := True;
finally
FreeMem(psd,dwLen);
end;