SharePoint Office 365 – How to Get the Lists with Unique Permissions – Programmatically C# CSOM

Sathish Nadarajan
SharePoint MVP
Published On :   06 Dec 2017
Visit Count
Today :  2    Total :   587
Plan, Migrate, Secure, Report
SharePoint & Office 365 Tool. Simple & Easy to Use. 15-Day Trial!

Sharegate: Kick-Ass Tool
Think Your SharePoint & Office 365 Are Secure ? Find Out Now!

In one of a requirement, need to get the Lists, which has unique permission. The input will be a Site Collection or a collection of site collections, we need to iterate through the webs inside that, and each list and prepare a list of Lists which has unique permission. Hence, thought of coming up with a small method and sharing with the community.

 public static void HasUniquePermission()
             OfficeDevPnP.Core.AuthenticationManager authMgr = new OfficeDevPnP.Core.AuthenticationManager();
             string siteUrl = "https://******";
             string userName = "Sathish@********";
             string password = "********";
             using (var ctx = authMgr.GetSharePointOnlineAuthenticatedContextTenant(siteUrl, userName, password))
                 Web web = ctx.Web;
                 List list = web.Lists.GetByTitle("D1");
                 ctx.Load(list, li => li.HasUniqueRoleAssignments);

The Property HasUniqueRoleAssignments gives back TRUE or FALSE.

Happy Coding,

Sathish Nadarajan.

SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.

Protect Your SharePoint