Пример #1
0
        public IDictionary <PermissionType, int> GetExplicitPermissionsInSubtree(int contentId, int[] identities, bool includeRoot)
        {
            var counters = _securityHandler.SecurityContext.GetExplicitPermissionsInSubtree(contentId, identities, includeRoot);
            var result   = new Dictionary <PermissionType, int>(PermissionType.PermissionCount);

            foreach (var item in counters)
            {
                result.Add(PermissionType.GetByIndex(item.Key.Index), item.Value);
            }
            return(result);
        }
Пример #2
0
        /// <summary>
        /// Collects all permission settings on the given content and its subtree related to the specified user or group.
        /// Output is grouped by permission types and can be filtered by the permission value or content type.
        /// </summary>
        /// <param name="contentId">Id of the content.</param>
        /// <param name="level">Filtering by the permission value. It can be Allowed, Denied, AllowedOrDenied.</param>
        /// <param name="explicitOnly">Filter parameter for future use only. Allowed value is true.</param>
        /// <param name="identityId">Id of the group or user.</param>
        /// <param name="includedTypes">Filter by content type names.</param>
        public IDictionary <PermissionType, int> GetRelatedPermissions(int contentId, PermissionLevel level, bool explicitOnly, int identityId, IEnumerable <string> includedTypes)
        {
            var filter   = new ContentTypeFilterForGettingRelatedPermissions(includedTypes);
            var counters = _securityHandler.SecurityContext.GetRelatedPermissions(contentId, level, explicitOnly, identityId, filter.IsEnabled);
            var result   = new Dictionary <PermissionType, int>(PermissionType.PermissionCount);

            foreach (var item in counters)
            {
                result.Add(PermissionType.GetByIndex(item.Key.Index), item.Value);
            }
            return(result);
        }
Пример #3
0
        /// <summary>
        /// Resets the allowed and denied permissions by the passed bitmask.
        /// </summary>
        /// <param name="entityId">The requested entity.</param>
        /// <param name="identityId">The requested identity.</param>
        /// <param name="localOnly">Determines whether the edited entry is inheritable or not.</param>
        /// <param name="permissionMask">Contains one or more permissions to allow or deny.</param>
        /// <returns>A reference to this instance for calling more operations.</returns>
        public new SnAclEditor Reset(int entityId, int identityId, bool localOnly, SenseNet.Security.PermissionBitMask permissionMask)
        {
            var permissionsToReset = new List <SenseNet.Security.PermissionTypeBase>();
            var bits = permissionMask.AllowBits | permissionMask.DenyBits;

            for (var i = 0; i < PermissionType.PermissionCount; i++)
            {
                if ((bits & (1uL << i)) != 0)
                {
                    permissionsToReset.Add(PermissionType.GetByIndex(i));
                }
            }
            ClearPermission(entityId, identityId, localOnly, permissionsToReset.ToArray());
            return(this);
        }