Skip to content

Instantly share code, notes, and snippets.

View jlattimer's full-sized avatar

Jason Lattimer jlattimer

View GitHub Profile
@jlattimer
jlattimer / Create CRM VM Static IP New.ps1
Last active August 29, 2015 14:10
PowerShell commands to create a new Azure virtual machine with a reserved IP address. Suitable for a Dynamics CRM test environment with ADFS.
<# Make sure you have installed the Azure PowerShell cmdlets: https://www.windowsazure.com/en-us/manage/downloads/ and then reboot #>
<# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
The steps need to be run individually
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #>
<# Step 1: Run this first to download your publisher file from Azure #>
Get-AzurePublishSettingsFile
<# Step 2: Change the path to the file you downloaded: C:\xxx\xxx.publishsettings #>
@jlattimer
jlattimer / Create CRM VM Static IP Existing.ps1
Created December 5, 2014 17:49
PowerShell commands to use an existing Azure virtual machine with a reserved IP address. Suitable for a Dynamics CRM test environment with ADFS.
<# Make sure you have installed the Azure PowerShell cmdlets: https://www.windowsazure.com/en-us/manage/downloads/ and then reboot #>
<# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
The steps need to be run individually
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #>
<# Step 1: Run this first to download your publisher file from Azure #>
Get-AzurePublishSettingsFile
<# Step 2: Change the path to the file you downloaded: C:\xxx\xxx.publishsettings #>
@jlattimer
jlattimer / CrmAuth.bas
Created February 6, 2015 05:25
Dynamics CRM VBA SOAP only authentication
Attribute VB_Name = "CrmAuth"
Option Explicit
' Use the PtrSafe attribute for x64 installations
Private Declare PtrSafe Function FileTimeToLocalFileTime Lib "Kernel32" (lpFileTime As FILETIME, ByRef lpLocalFileTime As FILETIME) As Long
Private Declare PtrSafe Function LocalFileTimeToFileTime Lib "Kernel32" (lpLocalFileTime As FILETIME, ByRef lpFileTime As FILETIME) As Long
Private Declare PtrSafe Function SystemTimeToFileTime Lib "Kernel32" (lpSystemTime As SYSTEMTIME, ByRef lpFileTime As FILETIME) As Long
Private Declare PtrSafe Function FileTimeToSystemTime Lib "Kernel32" (lpFileTime As FILETIME, ByRef lpSystemTime As SYSTEMTIME) As Long
Public Type FILETIME
@jlattimer
jlattimer / BasicBracketedArgumentListAnalyzer.cs
Last active August 29, 2015 14:15
Simple Dynamics CRM code analyzer using the .NET Compiler Platform ("Roslyn")
public override void Initialize(AnalysisContext context)
{
context.RegisterSyntaxNodeAction(AnalyzeBal, SyntaxKind.BracketedArgumentList);
}
private static void AnalyzeBal(SyntaxNodeAnalysisContext context)
{
SyntaxNode node = context.Node;
if (!node.IsKind(SyntaxKind.BracketedArgumentList)) return;
@jlattimer
jlattimer / BasicBracketedArgumentListCodeFix.cs
Created February 22, 2015 03:17
Simple Dynamics CRM code fix using the .NET Compiler Platform ("Roslyn")
public sealed override async Task ComputeFixesAsync(CodeFixContext context)
{
var root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);
var diagnostic = context.Diagnostics.First();
var diagnosticSpan = diagnostic.Location.SourceSpan;
// Find the type declaration identified by the diagnostic.
var declaration = root.FindToken(diagnosticSpan.Start).Parent;
@jlattimer
jlattimer / CrmOauth.cs
Created April 30, 2015 04:00
Xamarin iOS log into Dynamics CRM and retrieve Access Token and uses Refresh Token to renew after expiration
using Foundation;
using Microsoft.IdentityModel.Clients.ActiveDirectory;
using System;
using System.Linq;
using System.Threading.Tasks;
using UIKit;
namespace YourNamespace
{
public class CrmOauth
@jlattimer
jlattimer / Xrm.CRMAuth.js
Last active June 5, 2016 20:55
Dynamics CRM JavaScript SOAP only authentication - this only works in mobile applications - not browsers!
//Requires jQuery - http://jquery.com/
//Requires jsSHA (sha1.js) - http://caligatio.github.io/jsSHA/
Xrm = window.Xrm || { __namespace: true };
Xrm.CRMAuth = Xrm.CRMAuth || { __namespace: true };
/// <summary>Gets a CRM Online SOAP header & expiration.</summary>
/// <param name="url" type="String">The Url of the CRM Online organization (https://org.crm.dynamics.com).</param>
/// <param name="username" type="String">Username of a valid CRM user.</param>
/// <param name="password" type="String">Password of a valid CRM user.</param>
@jlattimer
jlattimer / CrmAuth.php
Created January 30, 2015 05:45
Dynamics CRM PHP SOAP only authentication
<?php
// include "CrmAuthenticationHeader.php";
class CrmAuth {
/**
* Gets a CRM Online SOAP header & expiration.
*
* @return CrmAuthenticationHeader An object containing the SOAP header and expiration date/time of the header.
* @param String $username
@jlattimer
jlattimer / CrmAnnyangTabNavigation.js
Last active January 26, 2017 02:30
Use the annyang to navigate between tabs in Chrome
function TabNavigation() {
//Be sure to include annyang on the form
//https://cdnjs.cloudflare.com/ajax/libs/annyang/2.6.0/annyang.min.js
//https://github.com/TalAter/annyang
if (annyang) {
//'show me' is the beginning of the command
//anything said after that will be passed to the function where it's used
//to match the tab label to the spoken input to determine the focused tab
var command = {
"show me *name": function (name) {
string clientId = "00000000-0000-0000-0000-000000000000";
string clientSecret = "00000000000000000000000000000000000000000000";
string tenantId = "00000000-0000-0000-0000-000000000000";
//Retrieve the access token required for authentication
var getTokenTask = Task.Run(async () => await GetToken(clientId, clientSecret, tenantId));
Task.WaitAll(getTokenTask);
if (getTokenTask.Result == null)
throw new InvalidPluginExecutionException("Error retrieving access token");
//Deserialize the token response to get the access token