Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2005.08.21;
Скачать: 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 вся ветка

Текущий архив: 2005.08.21;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.039 c
14-1122815252
ROCKER***
2005-07-31 17:07
2005.08.21
Ламоразмы


1-1122963963
АМБ
2005-08-02 10:26
2005.08.21
Изменение размера формы при выполнении программы


3-1121063866
Catik
2005-07-11 10:37
2005.08.21
Как проверить наличие таблицы в БД ?


14-1122620383
syte_ser78
2005-07-29 10:59
2005.08.21
посоветуйте украинский интернет магазин


14-1122465564
ПЛОВ
2005-07-27 15:59
2005.08.21
Вопрос по шахматам