SharePoint 2013: Import, validate, and manage app licenses

Learn how to import and manage app licenses, as well as how to retrieve, validate, and communicate licensing states in your apps for SharePoint. Using the tools in the sample, developers can import test licenses, validate licenses, and manage license assignment within SharePoint.

C# (2.2 MB)
4.4 Star
1,676 times
Add to favorites
E-mail Twitter Digg Facebook

Solution explorer

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ImportLicense.aspx.cs" Inherits="LicenseSPAppSampleWeb.Pages.Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">
<head runat="server">
    <meta http-equiv="X-UA-Compatible" content="IE=9" />
    <script type="text/javascript" src=""> </script>
    <script type="text/javascript" src="SPUtils.js"> </script>

    <title>SP App licensing samples</title>
    <style type="text/css">
        .auto-style1 {
            width: 100%;

        .auto-style2 {
            width: 165px; 

<body  style="overflow:scroll;" onload="loadChromeControl('Import License', '<%=Session["SPHostUrl"]%>', '<%=Session["SPAppWebUrl"]%>');">
    <div id="chrome_ctrl_container"></div>

    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <div style="margin-left: 10%">
                    Use this page to import a test license for your app. The default values provided 
        match this Test App but you must change them to match the App whose license you 
        want to simulate.<br />
                    <br />
                    <br />
                    <strong>App Title</strong><br />
                    <asp:TextBox ID="importAppTitle" runat="server"
                        Width="263px">License Demo App</asp:TextBox>
                    <br />
                    <br />
                    <br />
                    Must match the one contained on your AppManifest.xml. Default value is the ID for this sample app. <br />
                    <asp:TextBox ID="importProductId" runat="server"
                    <br />
                    <br />
                    <strong>Provider Name</strong><br />
                    <asp:TextBox ID="importProviderName" runat="server" Width="225px">Microsoft SDK Demo</asp:TextBox>
                    <br />
                    <br />
                    <strong>License Type</strong><br />
                    <asp:DropDownList ID="importLicenseType" runat="server" AutoPostBack="True"
                    <br />
                    <br />
                    <strong>User limit</strong><br />
                    <asp:DropDownList ID="importUserLimit" runat="server" Enabled="False">
                        <asp:ListItem Value="0">Unlimited</asp:ListItem>
                    <br />
                    <br />
                    <strong>Expiration</strong><br />
                    <asp:DropDownList ID="importExpiration" runat="server" Enabled="False"
                        <asp:ListItem Value="0">NA</asp:ListItem>
                        <asp:ListItem Value="30">30 days</asp:ListItem>
                        <asp:ListItem Value="-1">-1 (expired)</asp:ListItem>
                        <asp:ListItem Value="9999">Unlimited</asp:ListItem>
                    <br />
                    <br />
                    <strong>Customer ID<br /> </strong>Simulates the identity of a purchaser; generate a new one if you want to import multiple license types for the same app (at the same time); otherwise the license will be overwritten.<br />
                    &nbsp;<asp:Button ID="generateCustomerId" runat="server" OnClick="generateCustomerId_Click"
                        Text="Generate New" />
                    <br />
                     <asp:Label ID="importPurchaserId" runat="server" Text="739835AE59FDE73E"></asp:Label>
                    <br />
                    <br />
                    <strong>Execute Import License</strong><br />
                    <table class="auto-style1">
                            <td class="auto-style2">
                                <asp:Button ID="ImportLicense" runat="server" Height="48px" OnClick="ImportLicense_Click" Text="Import License" Width="147px" />
                                <asp:Label ID="statusMessage" runat="server" ForeColor="Red"></asp:Label>
                                <br />
                    <br />
                    <br />
                    <br />
                    <br />
                    <br />
                    <br />