예제 #1
0
        private void SetRightsForItem(SPListItem item, List<RoleItem> roles, bool clear, bool expandUsers)
        {
            setRightsLog += item.FormUrlDisplay() + " | ClearRights:" + clear + " | ExpandUsers:" + expandUsers + "\n";

            if (clear) item.RemoveRights();

            foreach (RoleItem role in roles)
            {
                List<SPPrincipal> users = LoadUsers(item, role.For, expandUsers);
                SPRoleDefinition spRole = item.Web.RoleDefinitions.Cast<SPRoleDefinition>().SingleOrDefault(r => r.Id == role.Role_Name);
                if (spRole == null)
                {
                    log.LogError("Could not find permisson level: '" + role + "'");
                    continue;
                }

                item.SetRights(users, spRole, false);

                setRightsLog += spRole.Name + " : " + users.Select(l => l.LoginNameNormalized()).JoinStrings(", ") + "\n";
            }
        }