Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3934370
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:42:29+00:00 2026-05-19T23:42:29+00:00

I have the following code to add a group with a permission level to

  • 0

I have the following code to add a group with a permission level to a sharepoint list

SPGroup Contribute = web.SiteGroups["Staff"];
SPRoleDefinition ContributeDefinition = web.RoleDefinitions["Read"];
SPRoleAssignment ContributeRoleAssignment = new SPRoleAssignment(Contribute);
ContributeRoleAssignment.RoleDefinitionBindings.Add(ContributeDefinition);
list.RoleAssignments.Add(ContributeRoleAssignment);

which adds the group, but how would I do it if I want to revoke the permission to the list for this group?

thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T23:42:30+00:00Added an answer on May 19, 2026 at 11:42 pm

    If you need to remove whole role assgnment you can do:

    SPUser user = ...;
    list.RoleAssignments.Remove(user);
    

    If you need to revoke some definition binding you can do:

    SPUser user = ...;
    list.RoleAssignments.GetAssignmentByPrincipal(user).RoleDefinitionBindings.Remove(..);
    

    If that is not you want, please describe in more details.

    UPDATE:
    Here is the sample code which I’ve tested and it works. It will remove Contribute role and add Read role to target group. Please note, that I have non-english Sharepoint version, so ensure the names of roles.

    static void Main(string[] args)
    {
      using (SPSite site = new SPSite("site_url"))
      {
        using (SPWeb web = site.OpenWeb())
        {
          SPList list = web.GetList(web.Url + "/" + "list_url");
          SPGroup group = web.SiteGroups["target_group_name"];
          SPRoleDefinition contributeDef = web.RoleDefinitions["Contribute"];
          SPRoleDefinition readDef = web.RoleDefinitions["Read"];
          SPRoleAssignment contributeRole = new SPRoleAssignment(group);
          contributeRole.RoleDefinitionBindings.Add(contributeDef);
          if (!list.HasUniqueRoleAssignments) // required to make role change
            list.BreakRoleInheritance(true);
          var assignmentForGroup = list.RoleAssignments.GetAssignmentByPrincipal(group);
          assignmentForGroup.RoleDefinitionBindings.Remove(contributeDef);
          assignmentForGroup.RoleDefinitionBindings.Add(readDef);
          assignmentForGroup.Update();
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: SPList list = web.Lists[this.ListName]; SPListItem item = list.Items.Add(); now
I have a following code in python: group = parser.add_mutually_exclusive_group() group.add_argument('-a', '--add', dest='name_to_add', help='Add
I have the following code to add authentication cookie to the response and redirect
I have the following Powershell code: Add-Type -Assembly System.Configuration [ExeConfigurationFileMap] $configMap = New-Object ExeConfigurationFileMap
I have following code: os.chdir(os.path.dirname(os.path.realpath(__file__)) + /../test) path.append(os.getcwd()) os.chdir(os.path.dirname(os.path.realpath(__file__))) Which should add /../test to
I have the following code in a php page <div class=vmenu> <div class=first_li><span >Add
I have added a UIScrollVIew using IB. Then using the following code i add
I have the following php code which I want to add a delay too:
I have following code which seems to work fine: <%if group.employees.count > 0%> <td><%=
I have the following javascript code: var groupArray = []; groupArray.push($(#group).val()); var sendInfo =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.