示例#1
0
        private static void CopyPermissions(Node source, Node target)
        {
            if (source == null || source.ParentId == 0 || target == null)
            {
                return;
            }

            // copy permissions from the source content, without reseting the permission system
            SecurityHandler.CopyPermissionsFrom(source.Id, target.Id, CopyPermissionMode.BreakAndClear);

            // If there were any permission settings for the Creators group on the source content, we
            // need to place an explicite entry with the same permissions onto the target for the creator
            // user, as the creator of the trashbag (the user who deletes the content) may be different
            // than the creator of the original document.
            var aces = SecurityHandler.GetEffectiveEntriesAsSystemUser(source.Id, new[] { Identifiers.OwnersGroupId }, EntryType.Normal);

            foreach (var ace in aces)
            {
                SecurityHandler.CreateAclEditor().Set(target.Id, ace.IdentityId, ace.LocalOnly, ace.AllowBits, ace.DenyBits);
            }

            aces = SecurityHandler.GetEffectiveEntriesAsSystemUser(source.Id, new[] { Identifiers.OwnersGroupId }, EntryType.Sharing);
            foreach (var ace in aces)
            {
                SnAclEditor.Create(SecurityHandler.SecurityContext, EntryType.Sharing).Set(target.Id, ace.IdentityId, ace.LocalOnly, ace.AllowBits, ace.DenyBits);
            }
        }