Ejemplo n.º 1
0
        public static bool DoesUserHavePermissionLevel(SPList list, string loginName, string permissionLevel)
        {
            var web = list.ParentWeb;

            if (!web.DoesUserHavePermissions(SPBasePermissions.ManageWeb))
            {
                return(DoesUserHavePermissionLevel(web.Site.ID, web.ID, list, loginName, permissionLevel));
            }

            var permissionInfo = list.GetUserEffectivePermissionInfo(loginName);

            return(permissionInfo.RoleAssignments
                   .SelectMany(roleAssignment => roleAssignment.RoleDefinitionBindings.Cast <SPRoleDefinition>())
                   .Any(roleDefinition => roleDefinition.Name == permissionLevel));
        }
Ejemplo n.º 2
0
        public static bool DoesUserHavePermissionLevel(SPList list, string loginName, string permissionLevel)
        {
            var web = list.ParentWeb;

            if (!web.DoesUserHavePermissions(SPBasePermissions.ManageWeb))
            {
                return DoesUserHavePermissionLevel(web.Site.ID, web.ID, list, loginName, permissionLevel);
            }

            var permissionInfo = list.GetUserEffectivePermissionInfo(loginName);
            return permissionInfo.RoleAssignments
                .SelectMany(roleAssignment => roleAssignment.RoleDefinitionBindings.Cast<SPRoleDefinition>())
                .Any(roleDefinition => roleDefinition.Name == permissionLevel);
        }