Tag Archives: Development

VIDEO – Protect WebAPI data endpoint with ADAL (Azure AD)

Wanted to record brief demo of how to protect WebAPI data endpoint with ADAL (Azure Active Directory) Authentication Library.   Azure Portal enables us to register custom SPA (Single Page Application) for secure API calls to backend REST data sources.   OAuth Bearer HTTP headers are applied to provide security with JWT tokens (JSON Web Token).   Video shows all steps from Azure Portal registration to F12 validation of REST data calls.

Cheers  shades_smile

Video

Screenshots

image

image

image

image

image

image

image

image

Code


References

VIDEO – Create SharePoint Framework (SPFx) “Hello World” Web Part

The video below demo shows how to create a new SPFx SharePoint Framework web part including Gulp, Visual Studio code, project folder tour, and TypeScript import references.

Great way to start developing for Modern pages (SharePoint Online and SharePoint 2016) running localhost on a developer workstation.  No need for a SharePoint virtual machine.  Cheers!  shades_smile

Video

References

SharePoint as a Service (SPaaS)

SharePoint is often treated as a final SAAS product to perform Microsoft native functions only.  Management can be reluctant to engage customization and development for the perceived cost. 

However, what is the cost of lacking a needed business tool?  Lost productivity and opportunity?  

What is the cost to create native SP features?   Make a blank IIS website?  Then create your own search, audit, permission interface, file store, REST endpoint, etc.?

 

Today is the best time ever to be a developer.  Many services and many tools.   Agile design can be applied to leverage 90% native platform with 10% custom code to spin up helpful business applications with low cost.   Micro services, REST api, and JavaScript frameworks provide the building blocks.   Developers are challenged to learn these new tools.  Ones that do can help deliver business value faster than ever.

 

Remember, SharePoint is a service– not the final product.  shades_smile

 

Features

  • Authentication – User context.  Password management, new account creation, integrated single sign-on.
  • Permissions – Groups, roles, custom permission levels,
  • Tables & Files – Storage of flat database (rows, columns, validated input, query) and binary files (folder, files)
  • Notification – Alert on data changes.  Daily and weekly summary.  Custom email body with Workflow.
  • Search – Index content, word parsing, custom results display, full REST api.
  • Audit – Regulatory compliance.  Reports, export, filter, and granular detail.
  • … and many more

 

Diagram

image

 

References

SharePoint 2013 – App Model 3 Tier Diagram

I needed a quick reference to introduce developers with the SharePoint 2013 App Model. 

For traditional ASP.Net and Dot Net coders there is a wide philosophy gap to cross when considering new applications written mostly in front-end JavaScript, HTML, and CSS.   Instead of coding “in” SharePoint (to augment the core product) we now code “next to” SharePoint (with additive REST/JSON endpoints).  

The stability which comes from this approach is significant.  We wan to run on-premise SharePoint similar to how Microsoft operates Office 365.   No more SharePoint customization lost during patching.   No more late night WSP and IISRESET outages.   Code can be modified more fluidly and IE breakpoints can even be set at a single user’s desktop when troubleshooting.   Exciting and powerful tools – which require a new way of thinking.

Please fee free to download the poster I made below.   Hope you find it helpful!  shades_smile

 

12-27-2014 3-07-04 PM

Merry Christmas – HTML5, JS, and CSS3

I wanted to thank all of you for reading my blog and wishing you a Happy Holiday season.   After passing exam 070-480 about HTML5, it seemed like a great time to practice new skills and draw a <CANVAS> based Christmas Tree here.   Enjoy!   Smile

 

Screenshot of what it should look like:

image

Code behind:


 

Live working demo:



Merry Christmas!

Say Happy Birthday with Code!

Most people just say “Happy Birthday” to each other over social networks like Facebook and Twitter with the same 14 predictable letters.   Why not say it with code?   If you’re a developer you already understand.   Smile   Before you ask … Yes, I really did write and run the QBasic 4.5 version in 16-bit mode running www.DosBox.com on Windows 7 x64.   Oh, and no it’s not my birthday.

 

With PowerShell

1..4 | % {if ($_ -ne 3) {Write-Host "Happy Birthday to You!"} else {"Happy Birthday Dear Jeff"}}

With C# Console Application

for (int i = 0; i <= 3; i++) { Console.WriteLine(((i == 2) ? "Happy Birthday dear Jeff" : "Happy Birthday to You!")); }

With JavaScript

With Command Prompt

@ECHO OFF
FOR %%A IN (1 1 2 1)
DO (
IF %%A == 1 ECHO "Happy Birthday to You!"
IF %%A == 2 ECHO "Happy Birthday dear Jeff"
) 
:EOF

With QBasic 4.5  (oh yes I did!)

CLS
FOR x = 1 TO 4
        IF x = 3 THEN
                PRINT "Happy Birthday dear Jeff!"
        ELSE
                PRINT "Happy Birthday to You!"
        END IF
NEXT x
FOR x = 37 TO 1000
        SOUND x, 1
NEXT x

 

image

image

image

image

An Unhandled exception CryptographicException occurred in OWSTIMER.EXE

I recently saw this error while patching SharePoint with a Cumulative Update.   Most people will never see this.  However, you are not most people.  You run Visual Studio.  Smile

Visual Studio is trying to help us out with an unhandled exception by asking about launching debug.  That’s all well and good but I didn’t write the code and have no plans to change it.

Best way to work with this is to disable the JIT (Just-In-time Debugger) by following a few simple Registry Key changes:  http://social.msdn.microsoft.com/Forums/en-US/vsdebug/thread/9e6cb3fb-f8fb-4c22-8608-e521e13260ff

 

image

Visual Studio Just-In-Time Debugger

An unhandled exception (‘System.Security.Cryptography.CryptographicException’) occurred in OWSTIMER.EXE [1344]

Programmatically enabling Records Management

Recently I had someone ask about how In-Place Records Management could be enabled in SharePoint 2010 for a given document with C# object model code.  The method ConfigureListForAutoDeclaration() was key to making everything work.  This would allow for easily enabling on many sites all at once.  Below I’ve included C# code and screenshots from the test site where it was enabled.  Please feel free to leave any questions below with a comment.

  • Open site
  • Enable “In-Place Records Management” site collection feature  (da2e115b-07e4-49d9-bb2c-35e93bb9fca9)
  • Open document library
  • Open “Record declaration settings”
  • Enable “Automatic Declaration” with [Microsoft.Office.Policy.dll]
  • Upload test files
  • Confirmed:  see padlock icon and unable to delete document library

 

C# – Visual Studio 2010 Console Application

Add assembly reference to [C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions14ISAPIMicrosoft.Office.Policy.dll]

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft;
using Microsoft.SharePoint;
namespace SharePointConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string siteURL = "http://sp2010";
            using (SPSite site = new SPSite(siteURL))
            {
                SPWeb w = site.OpenWeb();
                SPList dl;
                bool needToCreate = false;
                try
                {
                    dl = w.Lists["Records"];
                    Console.WriteLine("found");
                }
                catch (System.ArgumentException)
                {
                    needToCreate = true;
                }
                if (needToCreate)
                {
                    //missing so create it
                    Console.WriteLine("Records DL missing on " + w.Url);
                    Guid g = w.Lists.Add("Records", "** Coporate Records Management **", SPListTemplateType.DocumentLibrary);
                    w.Update();
                    dl = w.Lists[g];
                    //enable auto-Record for uploads
                    Microsoft.Office.RecordsManagement.RecordsRepository.Records.ConfigureListForAutoDeclaration(dl, true);
                    //add CEWP to default view
                    dl = w.Lists[g];
                    //show on QuickLaunch
                    if (!dl.OnQuickLaunch)
                    {
                        dl.OnQuickLaunch = true;
                        dl.Update();
                    }
                    //disable folders
                    if (dl.EnableFolderCreation)
                    {
                        dl.EnableFolderCreation = false;
                        dl.Update();
                    }
                    //enable Content Types
                    if (!dl.ContentTypesEnabled)
                    {
                        dl.ContentTypesEnabled = true;
                        dl.Update();
                    }
                    //disable Required Check Out
                    if (dl.ForceCheckout)
                    {
                        dl.ForceCheckout = false;
                        dl.Update();
                    }
                    //add Content Type to default view
                    Console.WriteLine("CT");
                    SPField ctField = dl.Fields["Content Type"];
                    SPView defaultView = dl.Views[dl.DefaultView.ID];
                    defaultView.ViewFields.Add(ctField);
                    defaultView.Update();
                    dl.Update();
                }
            }
        }
    }
}

Screenshots

image

DisplayName

Id

Scope

RecordResource

5bccb9a4-b903-4fd1-8620-b795fa33c9ba

Site

RecordsManagement

6d127338-5e7d-4391-8f62-a11e43b1d404

Farm

InPlaceRecords

da2e115b-07e4-49d9-bb2c-35e93bb9fca9

Site

RecordsCenter

e0a45587-1069-46bd-bf05-8c8db8620b08

Web

image

image

image

image

image

Best of SharePoint 2010 VSIX

The more I learn about Visual Studio 2010 the more I like it. For SharePoint developers, it is great to finally have a mature toolset. To make that experience even better the community has created several VSIX extensions as a “quick start” to more easily jump into various project types. Below I outline links to the VSIX extensions I am aware of and run locally. If you have any questions or suggestions please leave a comment.  Cheers!   Smile

 

image

 

CKS:DEV – Community Kit for SharePoint: Development Tools

http://cksdev.codeplex.com/

SharePoint Foundation 2010 version and SharePoint Server 2010 version

WSPBuilder conversion tool (WCT) beta

Improved Quick Deploy

Keyboard shortcuts

Updated Full Trust Proxy SPI

Restart processes menus

Attach to processes menus

Solution level Package all

Improved import Content Types

Branding SPI

Improved Fluent visual web part SPI

Basic service application SPI

WCF service SPI

SharePoint PowerShell cmdlet SPI

SharePoint PowerShell pipe binding SPI

Improved copy assembly name menu

SharePoint 2010 Extensibility Projects

http://archive.msdn.microsoft.com/vsixforsp/

  • Silverlight and SharePoint project template
  • SharePoint Ribbon project template
  • OBA Deployment project template

Visual Studio 2010 SharePoint Power Tools

http://visualstudiogallery.msdn.microsoft.com/8e602a8c-6714-4549-9e95-f3700344b0d9

  • Sandboxed-compatible Visual Web Part
  • Sandboxed Compilation

Silverlight SharePoint Web Parts

http://visualstudiogallery.msdn.microsoft.com/e8360a85-58ca-42d1-8de0-e48a1ab071c7

  • Silverlight Web Part
  • Silverlight Custom Web Part

SharePoint 2010 Timer Job

http://visualstudiogallery.msdn.microsoft.com/ab2b2d63-de37-4f63-b4b0-442f80b59b00

SharePoint 2010 Console Application

http://blah.winsmarts.com/2011-2-SharePoint_2010_Console_App,_Project_Template.aspx

LINQ to SharePoint DSL Extension for Visual Studio 2010

linq2spdsl

Windows Azure – publishing from Visual Studio 2010 (step-by-step with screenshots)

Today I deployed my first Azure application and documented the step-by-step process with detailed screenshots.

First I downloaded the Azure SDK and prepared Visual Studio 2010.   Azure is a cool idea because of the support for highly scalable custom code.  One frequent objection to cloud hosting is the basic functionally.   Cloud providers tend to offer what’s easy and convenient … while avoiding custom code.    Hybrid models may be the resolution.  Architects who can connect multiple vendors seamlessly or blend on-premise with in-cloud servers will be in demand.

  • Download the Azure SDK
  • Locate the first Hands On Lab (HOL) “Introduction to Windows Azure”
  • Code and build in Visual Studio 2010
  • Verify local Azure Emulator is working (files / SQL database / Compute)
  • Deploy to Azure in the cloud  (NOTE – this is  lot of work the first time,  must get connected and trusted)

 

image

 

We begin with the "Guest Book” sample application which allows you to post messages on a common wall with a picture attached.  Simple enough.

image

image

 

Here you can see the tray Azure Emulator running the website locally on my laptop.   For development you want to run things locally, test, and deploy to the cloud when stable.

image

image

 

Right clicking on the tray icon allows you to view Emulator status, logs, and details.   You can restart and control instances here.

image

 

Out of curiosity I opened SQL Management Studio  and viewed the “SQLEXPRESS” instance (which the default for the Azure SDK examples).  Here you can see the databases and tables this sample created.  The schema appears very abstracted.   From Visual Studio 2010 all I saw were strongly typed Classes and Objects for data.   Somehow that is being flattened to a database table using the Azure binaries, pretty cool.

image

 

Here is the Visual Studio 2010 Solution Explorer showing the 3 projects and related files inside of the “Guest Book” sample application.

image

 

OK, let’s get to the fun part.   Open a web browser, navigate to https://manage.windowsazure.com/ and login to Windows Azure Platform Management.  There is some new vocabulary which be confusing at first.   First, create a new “Hosted Service.   This can take 5-10 minutes to provision so be patient.

image

 

Once the “Hosted Service” shows “Created” then we must add a “Storage Account” for the ability to hold data in the cloud.

image

 

Certificate trusting the local laptop’s Visual Studio 2010 to publish.   This is a LOT of work, but only a one time operation.  Let’s get started.   Right click on your Azure project within the solution explorer and click Publish.

image

 

The first time here we need to Add Credentials.

image

 

To pair the local Visual Studio with the Azure cloud, we need a certificate.   Since this is our first time, create a new one.  Name it whatever you like.  I chose to name mine after the development laptop “JEFF-PC”

image

image

 

Click “copy the full path” to populate the clipboard with the local file path.

image

image

 

We’re going to leave Visual Studio 2010 for a minute, but keep it open in the background since we’ll be back.  In the web browser go back to Windows Azure Platform Management.  Click “add certificate” and paste the local .CER file path from the previous setup.

image

image

 

Click on the “Subscription” line item to view the “Subscript ID” number.  Copy this to the clipboard.  You will need to give that to Visual Studio 2010 locally for publishing.

image

 

Back in Visual Studio 2010 we need to finish the Add dialog by giving it two values:   Subscription ID and Name.

image

image

image

image

image

Congratulations!!   Hot  You’ve successfully connected your local Visual Studio 2010 to the Azure Subscription.   You should now see three cascading drop down menus with the Azure cloud deployment destinations.

Return to Top ▲Return to Top ▲