Вниз
Скачать: CL | DM;

Помогите создать DACL   Найти похожие ветки 

 
Pearled ©   (2005-07-01 16:41) [0]

Нашел в MSDN пример на С++ создания стандартного DACL для каталога.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/secbp/security/creating_a_dacl.asp
Попытался переписать в Delphi, но, видимо, что-то сделал не так, потому что не работает.. Ошибка происходит при вызове функции СonvertStringSecurityDescriptorToSecurityDescriptor.
В чем может быть ошибка? или может есть более легкий способ создания DACL?

function ConvertStringSecurityDescriptorToSecurityDescriptor(
StringSecurityDescriptor: LPCTSTR; StringSDRevision: DWORD;
SecurityDescriptor: PPSECURITY_DESCRIPTOR; SecurityDescriptorSize: PULONG): BOOL;
external "advapi32.dll" name "ConvertStringSecurityDescriptorToSecurityDescriptorA"

...

function CreateMyDACL(pSA: PSECURITYATTRIBUTES): BOOL;
var
  szSD: string;
  pc: PChar;
begin
szSD:= "D:" +    // Discretionary ACL
"(D;OICI;GA;;;BG)" +    // Deny access to built-in guests
"(D;OICI;GA;;;AN)" +    // Deny access to anonymous logon
"(A;OICI;GRGWGX;;;AU)"+  // Allow read/write/execute to authenticated users
"(A;OICI;GA;;;BA)";    // Allow full control to administrators
GetMem(pc,length(szSD)+1);
StrPCopy(pc,szSD);
if (pSA = nil) then
  result:= false
else
  result:= ConvertStringSecurityDescriptorToSecurityDescriptor(
               pc,
               1,
               pSA^.lpSecurityDescriptor,
               nil);
end;

procedure main;
var
 sa: PSECURITYATTRIBUTES;
begin
sa^.nLength:= sizeof(SECURITY_ATTRIBUTES);
sa^.bInheritHandle:= FALSE;
if CreateMyDACL(sa) then
...........


 
BiN ©   (2005-07-01 17:22) [1]



function ConvertStringSecurityDescriptorToSecurityDescriptor(StringSecurityDescriptor: LPCSTR;
 StringSDRevision: DWORD; var SecurityDescriptor: PSECURITY_DESCRIPTOR;
 SecurityDescriptorSize: PULONG): BOOL; stdcall; external advapi32 name "ConvertStringSecurityDescriptorToSecurityDescriptorA";

{$EXTERNALSYM ConvertStringSecurityDescriptorToSecurityDescriptor}

...

procedure TSecurityDescriptor.SetSDDLString;
var
 SRSecDesc: PSecurityDescriptor;
begin
 if ConvertStringSecurityDescriptorToSecurityDescriptor(Pchar(StringSecurityDescriptor),
                                                        SDDL_REVISION_1,
                                                        SRSecDesc, nil)
 then
 begin
   try
     SetSecurityDescriptor(SRSecDesc);
   finally
     LocalFree(HLOCAL(SRSecDesc));
   end;
 end
 else RaiseLastOSError;
end;



 
BiN ©   (2005-07-01 17:26) [2]

Паараметры в догонку:
procedure TSecurityDescriptor.SetSDDLString(const StringSecurityDescriptor: String);

В том же msdn есть пример SDDL-строк.



Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.45 MB
Время: -0.976 c
1-1122919832
kingdom
2005-08-01 22:10
2005.08.21
Выпадающее меню.


3-1121284333
BBCHa
2005-07-13 23:52
2005.08.21
Округление средствами SQL


4-1119766404
Гость2
2005-06-26 10:13
2005.08.21
Как дождаться выполнения bat-файла?


14-1122741224
TUser
2005-07-30 20:33
2005.08.21
Я скорее доверюсь Ивану с разводным ключом,


4-1120277194
mr.IL
2005-07-02 08:06
2005.08.21
AveSync




   Наверх