5

I want to prevent users from accessing some document libraries.

I have used the following code but it didn't work, Any solution?

 doclibraryinstanse.Hidden = true;
 doclibraryinstanse.Update();
 clientcontext.Load(doclibraryinstanse);
 clientcontext.ExecuteQuery();
5

Using List.Hidden property to make it hidden from UI is not enough to prevent users from accessing it.

Consider to utilize List.BreakRoleInheritance to specify unique role assignments for a List, for example:

 var list = ctx.Web.Lists.GetByTitle(listTitle);
 list.Hidden = false;
 list.BreakRoleInheritance(false,false); //clear role assignments for a List
 list.Update();
 ctx.ExecuteQuery(); 
1

You can break the inheritance of these document library and remove their link from quick launch. After breaking its inheritance, remove users from its permission settings who should not access to this document library.

It should work like a charm!

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.