I am trying to add a new Group to an existing Publication and assign Component Management permission as shown in the snippet below.
While using the below mentioned code I do not receive any error but the security Group is not added to the access control list of the Publication.
PublicationData oPublicationData = (PublicationData)client.Read(
publicationId, new ReadOptions());
PublicationData pubData = SetRightsOnPublication(oPublicationData, trustee,
Rights.ComponentManagement);
client.Update(pubData, new ReadOptions());
public static PublicationData SetRightsOnPublication(PublicationData oPublicationData,
TrusteeData trusteeId, Rights allowedRights, Rights deniedRights = Rights.None)
{
var entries = oPublicationData.AccessControlList.AccessControlEntries.ToList();
// First check if this trustee already has some permissions
var entry = entries.SingleOrDefault(ace => ace.Trustee.IdRef == trusteeId.Id);
if (entry != null)
{
// Remove this entry
entries.Remove(entry);
}
entries.Add(new AccessControlEntryData
{
AllowedRights = allowedRights,
DeniedRights = deniedRights,
Trustee = new LinkToTrusteeData { IdRef = trusteeId.Id, Title = trusteeId.Title,
Description = trusteeId.Description }});
oPublicationData.AccessControlList.AccessControlEntries = entries.ToArray();
return oPublicationData;
}