In this article we will be seeing how to get all the permission levels in SharePoint 2010 using C# and powershell script. In this article
Steps involved:
How to get all the permission levels using C#: using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.SharePoint;
namespace CustomPermissionLevel { class Program { static void Main(string[] args) { using (SPSite site = new SPSite("http://servername:2020/")) { using (SPWeb web = site.RootWeb) { SPRoleDefinitionCollection roleColl = web.RoleDefinitions; foreach (SPRoleDefinition role in roleColl) { Console.WriteLine(role.Name.ToString()); } Console.ReadLine(); } } } } }
How to get all the permission levels using powershell script $site=Get-SPSite "http://servername:2020/" $web=$site.RootWeb $roleColl=$web.RoleDefinitions foreach($role in $roleColl) { write-host $role.Name } Properties of SPRoleDefinition: $site=Get-SPSite "http://servername:2020/" $web=$site.RootWeb $roleColl=$web.RoleDefinitions $role= $roleColl["Custom Permission Level Test"] Write-host $role
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: