title: How to remove user permissions from a SharePoint 2013 document library using c#
body: <p>I've seen many ways to remove groups from a document library in SharePoint 2013. But what I need to do is to remove an individual's permissions to a document library and not a group.</p>
  
  <p>This is the code I've been using. It runs without error, but it fails to remove the users permission on the document library.</p>
  
  <p>I do not want to remove the user from any groups or from the site.</p>
  
  <pre><code>    public void DeleteUserFromDocumentLibrary(string fullUserLogon, string shareName)
      {
          string Myurl = "https://host.domainname.com/fs";
  
          using (SPSite site = new SPSite(Myurl))
          {
              site.AllowUnsafeUpdates = true;
  
              using (SPWeb web = site.OpenWeb())
              {
                  web.AllowUnsafeUpdates = true;
                  web.ValidateFormDigest();
  
                  fullUserLogon = "i:0#.w|" + fullUserLogon;
                  SPPrincipal principal = web.EnsureUser(fullUserLogon);
                  SPRoleAssignment rAssignment = new SPRoleAssignment(principal);
                  SPList list = web.Lists[shareName];
  
                  foreach (SPListItem item in list.Items)
                  {
                      item.BreakRoleInheritance(true);
                      item.RoleAssignments.Remove(principal);
                      item.Update();
                  }
  
  
                 web.AllowUnsafeUpdates = false;
              }
              site.AllowUnsafeUpdates = false;
          }
      }
  </code></pre>
  
  <p>Thanks</p>