2

After assigning permissions to a group on a Sharepoint list, the users of the group trying to access said list get the Microsoft.SharePoint.Client.ServerException: "The list « listTitleExample» does not exist at url «urlExample») "

The code below that I used to assign permissions to a group on a list exits with no errors and adds the RoleAssignments to the list and ClientContext.Web:

 var group = clientContext.Web.SiteGroups.GetById(id);   
 clientContext.Load(group);
 clientContext.ExecuteQuery();  

 BasePermissions permissions = new BasePermissions();
 permissions.Set(PermissionKind.ViewListItems); 

 RoleDefinitionCreationInformation rdcInfo = new 
 RoleDefinitionCreationInformation();
 rdcInfo.Name = "roleDefName";
 rdcInfo.Description = "Description";
 rdcInfo.BasePermissions = permissions;
 RoleDefinition roleDefinition = 
 clientContext.Site.RootWeb.RoleDefinitions.Add(rdcInfo);

 RoleDefinitionBindingCollection RoleDefinitionBindingColl = new 
 RoleDefinitionBindingCollection(clientContext);
 RoleDefinitionBindingColl.Add(roleDefinition);

 List targetList = web.Lists.GetByTitle(listTitle);
 targetList.BreakRoleInheritance(true, false);
 RoleAssignmentCollection collRoleAssign = targetList.RoleAssignments;
 RoleAssignment rollAssign = collRoleAssign.Add(group, RoleDefinitionBindingColl);

 web.RoleAssignments.Add(group, RoleDefinitionBindingColl);
 web.Update();
 clientContext.ExecuteQuery();

Only the users who were assigned permissions via the code above get the error.

  • Can you include code where you get reference for the 'group' variable? – SharePoint Badger Jul 25 '19 at 4:17
  • I've included the code where I get reference for the 'group' variable. I actually get the group by its ID then load it because I need its Title afterwards. – Bellatrix Aug 6 '19 at 8:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.