TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Identify Unique Permission of a Web Site
Shantha Kumar T
Sep 21
2015
Code
1
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
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();
Console.WriteLine();
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);
ctx.ExecuteQuery();
Console.WriteLine(
"Site \""
+ web.Title+
"\" has Unique Permission: "
+ web.HasUniqueRoleAssignments);
Console.Read();
}
private
static
string
getPassword()
{
ConsoleKeyInfo key;
string
pass =
""
;
do
{
key = Console.ReadKey(
true
);
// Backspace Should Not Work
if
(key.Key != ConsoleKey.Backspace && key.Key != ConsoleKey.Enter)
{
pass += key.KeyChar;
Console.Write(
"*"
);
}
else
{
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;
}
}
}
SharePoint
Permission