As part of a 'publishing' function, a group needs to be added or updated to the document security with read only scope. Here is a simplified code snippet (please excuse any errors in the snippet, the full code compiles under Delphi XE2 without errors):
procedure TForm1.publishContent(mDoc: IManDocument; toFolder: IManFolder);
var
dSec: IManSecurity;
oNam: Widestring;
oGrpACLs, dGrpACLs: IManGroupACLs;
oGrpACL, dGrpACL: IManGroupACL;
begin
oNam := 'TESTGROUP';
mDoc.Get_Security(dSec);
if (dSec <> nil) then
begin
dSec.Get_GroupACLs(dGrpACLs);
if (dGrpACLs <> nil) then
begin
dGrpACLs.ItemByName(oNam,dGrpACL);
if (dGrpACL <> nil) then
begin
// update groupACL, it exists so make sure READ only
dGrpACL.Set_Right(imRightRead);
end
else
begin
// not part of document, add groupACL to document
dGrpACLs.Add(oNam,imRightRead,dGrpACL);
end;
dGrpACLs.Refresh;
end;
end;
iResult := mDoc.UpdateWithResults(mResult);
end;
I've tested the case where the 'TESTGROUP' has been assigned to the document with a different security level and code is not able to change it to read only. In the case where the group does not exist for the document, the Add method does not add the group/. In either case no errors are reported. Ideas?