Monthly Archives: January 2017

VIDEO – Online WebAPI Generator

I created an online service at https://spjeff.azurewebsites.net/ which generates a MVC WebAPI 2.2 project with the name you enter.   A custom ZIP file is generated server side with your custom name for the Project, Namespaces, Assembly, and sent to the browser for download.   Best practices are already enabled such as:

  • [CORS] decorator
  • [Authorize] decorator
  • Minimal packages and dependency
  • Zero MVC boilerplate
  • Lean mean API ready for dev & prod

From there double click SLN and begin coding.  Enjoy!  shades_smile

 

Video

Online WebAPI Generator from Jeff Jones on Vimeo.

 

Screenshots

 

image

 

image

 

image

PowerShell – Cache AD User Lookup

Given a filter value, this PowerShell function will query Active Directory to find a matching user object and store results in a memory cache.  By default “samAccountName” is used for filter.  Optional field name can be provided to filter by any field such as Manager, Mail, or DN. 

Cheers!   shades_smile

 

 

Source Code

https://github.com/spjeff/spadmin/blob/master/lookupADUser.ps1

 

# DataTable cache
$cacheUsers = New-Object System.Data.DataTable("users")
$cols = @("DistinguishedName","Enabled","extensionAttribute4","Manager","Name","Mail","SamAccountName")
foreach ($col in $cols) {
	$cacheUsers.Columns.Add($col) | Out-Null
}

# Find user by any field
Function lookupADUser ($login, $optFieldName) {
    # Filter 
    $dv = New-Object System.Data.DataView($cacheUsers)
    $filter = "SamAccountName = '$login'"
    if ($optFieldName) {
        $filter = $filter.Replace("SamAccountName", $optFieldName)
    }
    $dv.RowFilter = $filter
    # Return from cache
    if ($dv.Count -gt 0) {
        # Found
	    return $dv
    } else {
        # Insert
        $cmd = "SamAccountName -eq '$login'"
        if ($optFieldName) {
            $cmd = $cmd.Replace("SamAccountName", $optFieldName)
        }
        $sb = [Scriptblock]::Create($cmd)
        $user = Get-ADUser -Filter $sb -Properties extensionAttribute4,manager,enabled,Mail
        if ($user) {
            $row = $cacheUsers.NewRow()
	        foreach ($col in $cols) {
		        $row[$col] = $user.$col
	        }
	        $cacheUsers.Rows.Add($row) | Out-Null
	        return $dv
        } else {
            return $null
        }
    }
}

# Search by userID
$sb = {lookupADUser "userID"}
measure-command $sb |ft
# Search by Email
$sb = {lookupADUser "first_last@company.com" "Mail"}
measure-command $sb |ft
# Search by DN
$sb = {lookupADUser "CN=First Last,OU=Regular,OU=Accounts,DC=company,DC=com" "DistinguishedName"}
measure-command $sb |ft

 

Screenshot

2017-01-27_14-18-07

What’s in that patch? Jan 2017

NOTE – PDF format updated to include both SharePoint 2013 and 2016 notes.

 

Ever wondered what fixes are inside of a given CU?   Please see attached PDF with full detail. I wanted a new format for easy reading.   Show management and make the business case for why downtime should be taken to apply CUs.  Also posted at http://sharepointupdates.com/

If you found this helpful, please leave a comment.    shades_smile_thumb_thumb_thumb_thumb[2]

 

Download

What’s in that patch – Jan 2017.PDF

Replace CE / SE Web Part Content PS1

Managing front end code (HTML/JS) embedded within Script and Content Editor Web Parts can be a hassle.   With multiple instances scattered across ASPX pages, web part galleries, and many sites quickly becomes untenable.

The below PowerShell script gives SharePoint admins a new way to search/replace the internal text of CEWP/SEWP web parts within a target site collection.    Updating a URL reference or DNS name can now be done across potentially hundreds  of WP in just a few minutes.

For example, a team site having 1 CEWP and 1 SEWP with the world “hello” can be quickly replaced with “hola” by running this script.

Cheers!  shades_smile

 

Source Code

 

Screenshot – Before

1

 

3

 

Screenshot – After

5

6

7

 

8

Simple URL Shortener

Recently I wanted to create a URL shortening service for SharePoint 2013.  Yes, SharePoint 2016 ships with “Durable Links” but many places run older version.   Yes, there are commercial software packages available for sale but management and budget approval can be challenging.

Why not create a simple redirect ASPX with a Custom List of URLs?

Check out the brief video below to see it running live.   The Install PS1 script will create the needed List and upload front end files (ASPX + JS).

 

Source Code

 

Video

 

Diagram

2017-01-10_14-30-07

VIDEO – Cloud migration of JS todo CRUD to Azure & Office 365 (part 2 of 2)

Live walk through of hosting “Todo List” CRUD application on the Microsoft cloud.   Continued from the first video where we coded a full local application, this video migrates the application front/back end to the cloud.   HTTPS Breeze WebAPI endpoint hosted on Azure for the backend with HTTPS Office 365 SharePoint Content Editor Web Part for the frontend GUI end user experience.

Custom HTTP header was added for extra security as an application “client secret” which is required for the WebAPI middle tier to respond to HTTP traffic.  Missing HTTP header will respond with “null” and not execute any Dot Net code.

Enjoy! shades_smile
 

 

Diagram

breezejs-sharepoint-architecture
 

Video

 

References

Return to Top ▲Return to Top ▲