我正在尝试将两个条目设置为同一组的对象文件夹,具有不同的继承,(一个为 FILE_TRAVERSE 的 NO_INHERITANCE,另一个为 SUB_CONTAINERS_AND_OBJECTS_INHERIT,用于 GENERIC_READ)。我看到每次最后一次通话都会覆盖先例。我在 delphi 中编写了这个(但如果是 C++ 或 C...,则相同)。有人可以帮我解决问题吗?
这是调用函数:
function setACL(const foldername:string;const SID:PSID;const AccessPermissions:cardinal;
const AccessMode:ACCESS_MODE;const Inheritance:cardinal;
const TrusteeType:TRUSTEE_TYPE):boolean;
var
pEA: PEXPLICIT_ACCESS_W;
pDACL: PACL;
R: DWORD;
begin
pEA := AllocMem(SizeOf(EXPLICIT_ACCESS_W));
pEA^.grfAccessPermissions:=AccessPermissions;
pEA^.grfAccessMode:=AccessMode;
pEA^.grfInheritance:=Inheritance ;
pEA^.Trustee.TrusteeForm:=TRUSTEE_IS_SID;
pEA^.Trustee.TrusteeType:=TrusteeType;
pEA^.Trustee.ptstrName:=PWideChar(sid);
R := SetEntriesInAcl(1, pEA, nil, pDACL);
if R = ERROR_SUCCESS then
begin
if SetNamedSecurityInfo(pchar(foldername),
SE_FILE_OBJECT,
DACL_SECURITY_INFORMATION,
nil,
SID,
pDACL,
nil) <> ERROR_SUCCESS then ShowMessage('SetNamedSecurityInfo failed: ' + SysErrorMessage(GetLastError));
LocalFree(Cardinal(pDACL));
end
else ShowMessage('SetEntriesInAcl failed: ' + SysErrorMessage(R));
end;
我这样称呼它两次:
Groupname:='myNet\aGroup';
Get_SID('wbox0',groupname,sid);//this function just to get SID
foldername := '\\wbox0\temp\filippo'; //the folder to set permissions
setACLGroupFolder(foldername,sid,FILE_TRAVERSE,SET_ACCESS,NO_INHERITANCE,TRUSTEE_IS_GROUP);
setACLGroupFolder(foldername,sid,GENERIC_READ,SET_ACCESS,SUB_CONTAINERS_AND_OBJECTS_INHERIT,TRUSTEE_IS_GROUP);
第二个调用替代第一个。最后,我没有得到同一组的两个条目。