Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
How To Get All Permission Levels In SharePoint 2013 Programmatically
WhatsApp
Manpreet Singh
8y
11.1
k
0
0
25
Blog
Welcome to a blog on how to get all permission levels in SharePoint 2013 programmatically using a console application. We will use Visual Studio to get all permission levels in SharePoint 2013 site.
Let’s see how to do it.
Open you Visual Studio.
Select New Project.
Select Console Application.
Add the references.
Microsoft.SharePoint dll and Microsoft.SharePoint.Client dll
Paste the code below under Program.cs.
Code
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Threading.Tasks;
using
Microsoft.SharePoint.Client;
namespace
Getallpermissionlevels {
class
Program {
static
void
Main(
string
[] args) {#call the web
ClientContext clientContext =
new
ClientContext(
"http://devtest.us01.apmn.org/SPTests/"
);
Web web = clientContext.Web;#
get
all permission levels
RoleDefinitionCollection roleDef = web.RoleDefinitions;
clientContext.Load(roleDef);#execute the code
clientContext.ExecuteQuery();#loop through all the permission levels
foreach
(RoleDefinition roleDefinition
in
roleDef) {
Console.WriteLine(roleDefinition.Name);
}#Display them here
Console.ReadKey();
}
}
}
Run the code and your document library will be created.
Get All Permission Levels
SharePoint 2013
Up Next
How to create custom sharepoint group and add permission level using powershell
Ebook Download
View all
Getting Started with SharePoint Framework Development using TypeScript, PnP JS, and React JS
Read by 4.9k people
Download Now!
Learn
View all
Membership not found