Identify Unique permission of a Web Site

The following example CSOM code snippet returns the Boolean value to identify the site has inherited permission or unique permission.

Web.HasUniqueRoleAssignments returns true, if the website has the unique permission
Web.HasUniqueRoleAssignments returns false, if the website is inherited the permission from the parent site.

Add the below reference dlls to the Visual Studio solution

[code lang=”csharp”]
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint.Client;
using System.Net;

namespace IdentifyWebPermission
class Program
static void Main(string[] args)
//Get Site Url fro user
Console.Write("Enter Site URL: ");
string strURL = Console.ReadLine();

//Get Username from user in the format of (Domain/Login ID)
Console.Write("Enter UserName (domain/userid): ");
string strUserName = Console.ReadLine();

Console.Write("Enter your password: ");
string pass = getPassword();

ClientContext ctx = new ClientContext(strURL);
ctx.Credentials = new NetworkCredential(strUserName, pass);
Web web = ctx.Web;
//Parameters to receive response from the server
//HasUniqueRoleAssignments property should be passed in Load method to get the value
ctx.Load(web, w => w.HasUniqueRoleAssignments, w => w.Title);
Console.WriteLine("Site \""+ web.Title+ "\" has Unique Permission: "+ web.HasUniqueRoleAssignments);

private static string getPassword()
ConsoleKeyInfo key;
string pass = "";
key = Console.ReadKey(true);
// Backspace Should Not Work
if (key.Key != ConsoleKey.Backspace && key.Key != ConsoleKey.Enter)
pass += key.KeyChar;
if (key.Key == ConsoleKey.Backspace && pass.Length > 0)
pass = pass.Substring(0, (pass.Length – 1));
Console.Write("\b \b");
// Stops Receving Keys Once Enter is Pressed
while (key.Key != ConsoleKey.Enter);
return pass;

Shantha Kumar
Shantha Kumar
Articles: 269

Leave a Reply

Your email address will not be published. Required fields are marked *