Tuesday, February 2, 2016

Develop SharePoint-hosted SharePoint Add-in to get user's permission at the site level

This article is a basic example of developing a SharePoint-hosted SharePoint Add-in and deploying to SharePoint online site

Source Code

Environment: Office 365, SharePoint Online, Visual Studio 2015, JSOM

Prerequisite: Active users are added to the Office 365 site and granted permission to access the SharePoint online.


Requirement: Develop a SharePoint-hosted SharePoint Add-in to get user's permission at the site level

Solution:
Create the add-in project


  1. Start Visual Studio
  2. Choose File > New > New Project.
  3. In the New Project dialog box, expand the Visual C# node, expand the Office/SharePoint node, and then choose Add-ins > Add-in for SharePoint.
  4. Name the project, and then choose OK.


Create SharePoint Add-in using Visual Studio


  1. Specify the Add-in for SharePoint Settings dialog box, provide the full URL of the SharePoint site that you want to use to debug your add-in. This is the URL of the Developer Site. (Use HTTPS, not HTTP in the URL.) Under How do you want to host your SharePoint Add-in, choose SharePoint-hosted. Choose Finish.


Specify the SharePoint Add-in settings.


  1. Provide your subscription administrator's credential if prompted to login to your Developer Site.


Connect to SharePoint


  1. In Specify the target SharePoint version page, select SharePoint Online, and then click Finish button


Specify the target SharePoint version


Code your add-in


Following is the project items created by default template. Refer to this MSDN article for more information about each project item
Solution Explorer


Publish the Add-in


Publish the SharePoint Add-in


Deploy the Add-in to the developer site.


Deploy the SharePoint Add-in to the developer site


Developer Site home page with the Add-ins in Testing list


Developer Site home page with the Add-ins


Run the add-in

Note: User running this app should have appropriate permission to get the permission level for other users. A full control permission is recommended in this case.


Run the add-in


Source Code is available at TechNet gallery.

No comments:

Post a Comment