Article
    C#
    ADO.Net
    .NET
    ASP.Net & Web Forms
    Custom Controls
    Web Development
    Exception Handling
    XML
    Database
    Security in .Net
    Testing
    Web Services
    Windows Services
    Windows Controls
    WCF
    AJAX
    WPF
    XAML
    Reporting
    Setup
    VB.Net
    LINQ
    JQuery
    SilverLight
    JavaScript
    HTML5
    Crystal Report
    Cloud Computing
    Share Point
    Visual C++
    MVC
    Android
    PHP
    Java
    HTML
    WordPress
    Joomla
    Products
    Drupal
    Windows Phone
    JSON
    LightSwitch
    iPhone/iPad
    Ruby on Rails
    IIS 7
    Windows 8
    CSS/CSS3
    Excel
    MS Access
    Shortcut Keys
    Visual SourceSafe
    Team Foundation Server
    API(s)
    Sencha-Touch
    Single Page App
    Bootstrap
Follow Us
Follow _MindStick_ on Twitter View MindStick Software's LinkedIn profile View MindStick Software's Facebook profile
Top Contributor
Advertisement
Advertise with Us
Mindstick
Article Article  Forum Forum  Blog Blog  Quiz Quiz  Beginner Beginner  Careers Careers  Contact Contact  Login Login  
Home | Product | Services | About Us | Interview | DeveloperSection | Submit an Article | Submit Blog

Home >> Share Point >> Getting the permission levels from SharePoint 2010 using C#
Getting the permission levels from SharePoint 2010 using C#
Getting the permission levels from SharePoint 2010 using C#


by Rohit Kesharwani on 12/14/2011 1:34:24 PM

Views: 5079       Comments: 1

Getting the permission levels from SharePoint 2010 using C#

In this article I am going to explain how to get all the permission levels in SharePoint 2010 using C#.

Steps involved:

  • Go to Visual Studio 2010.
  • Go to File à New à Project.
  • Select Windows Application and apply the following settings to your project:
    Target Framework: .NET 3.5
    Build output: AnyCpu (or x64)
  • Click Add.

Getting the permission levels from SharePoint 2010 using C#

Getting the permission levels from SharePoint 2010 using C#

Next, we need to add references. Right click the “References” node and choose “Add Reference”.

Getting the permission levels from SharePoint 2010 using C#

·         Choose Browse:

·         Go to the following location: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI.

·         Select Microsoft.SharePoint.dll files:

Add the following code in the Program.cs file:

using System;

using System.Collections.Generic;

using System.Text;

using Microsoft.SharePoint;

 

namespace SampleApplication1

{

    class Program

    {

        static void Main(string[] args)

        {

            using (SPSite site = new SPSite("http://rohit:34143/"))

            {

                using (SPWeb web = site.RootWeb)

                {

                    SPRoleDefinitionCollection roleColl = web.RoleDefinitions;

                    foreach (SPRoleDefinition role in roleColl)

                    {

                        Console.WriteLine(role.Name.ToString());

                    }

                    Console.ReadLine();

                }

            }

        }

    }

}

Output:

Getting the permission levels from SharePoint 2010 using C#

Thanks for reading this article. I think this will help you a lot.

Report Abuse Form
Reason:    
 


Getting the permission levels from SharePoint 2010 using C#
by Arun Singh 12/26/2011 4:50:07 AM
Hi Rohit,
This is one of the best answer so far, I  have read online. Just useful information. Very well presented. Thanks for sharing with us.
Report Abuse
Title :
Comment :
Text ColorBackground Color
BoldItalicUnderline
LeftCenterRightJustify
Ordered ListBulleted List
IndentOutdent
Horizontal Rule
SubscriptSuperscript
HyperlinkImage
Design ModeDesign
View HtmlHtml
     
 
Latest Article by Rohit KesharwaniRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Latest BlogsRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Top Viewed ArticlesRSS Feed
    
    
    
    
    
    
    
    
    
    
Top Viewed BlogsRSS Feed
    
    
    
    
    
    
    
    
    
    
Latest Interview QuestionsRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Total Online Users: 3012
Advertisement
MindStick Cleaner
Advertise with Us
  
Copyright © 2009 - 2014MindStick. All Rights Reserved.