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

  • Home
  • SEARCH
  • 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 that I need to add an additonal object to
I have the following code in a web.config file of the default IIS site.
I have the following code: SELECT <column>, count(*) FROM <table> GROUP BY <column> HAVING
I have following code which seems to work fine: <%if group.employees.count > 0%> <td><%=
I have the following code to add an Overlay myMapView.getOverlays().add(sites); myMapView.invalidate(); I also have
I have following code private static ObservableCollection<myColor> myItems = new ObservableCollection<myColor>(); myItems.Add(new myColor(red)); When
I have the following code: var data= from row in table.AsEnumerable() group row by
I have following code snippet in c#. var list = new List<string> { a,
I have the following code $(document).ready(function(){ // class exists if($('.delete').length) { // add click
I have the following code: CancellationTokenSource cancelSource = new CancellationTokenSource(); _cancelTokenList.Add(cancelSource); CancellationToken token =

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.