Skip to content

Instantly share code, notes, and snippets.

View michaelkc's full-sized avatar

Michael Christensen michaelkc

View GitHub Profile
using System;
using System.IdentityModel;
using System.Reflection;
using System.Text;
using System.Web;
namespace Samples
{
/// <summary>
/// A "DeflatedSaml" token header encoder. DeflatedSaml is a semi-standard, in that the encoding/compression steps are described in the SAML standards.
using System;
using System.IdentityModel.Protocols.WSTrust;
using System.IdentityModel.Tokens;
using System.Reflection;
using System.Security.Claims;
using System.Security.Cryptography.X509Certificates;
using System.ServiceModel;
using System.ServiceModel.Security;
using System.Text.RegularExpressions;
using System.Threading;
var wsTrustClient = new WsTrustClient("devtest-idp.vfltest.dk");
var audience = "https://devtest-ws-dli.vfltest.dk/UserServices/";
var token = (GenericXmlSecurityToken)wsTrustClient.GetSecurityToken(audience, "<service account>", "<service account password>");
var tokenXml = token.TokenXml.OuterXml;
var encodedToken = new DeflatedSamlTokenHeaderEncoder().Encode(tokenXml);
Console.WriteLine(tokenXml);
Console.WriteLine(encodedToken);
using (var client = new HttpClient())
{
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True,Position=1)]
[string]$csprojInFile,
[Parameter(Mandatory=$True,Position=2)]
[string]$csprojOutFile
)
$csproj = [xml](get-content $csprojInFile)
$xmlns = $csproj.Project.xmlns
@michaelkc
michaelkc / BoxStarter2012R2ADFS
Last active August 29, 2015 14:11
BoxStarter2012R2ADFS
# Invoke using following syntax:
# http://boxstarter.org/package/url?[input url to this gists]
# Boxstarter options
$Boxstarter.RebootOk=$true # Allow reboots?
$Boxstarter.NoPassword=$false # Is this a machine with no login password?
$Boxstarter.AutoLogin=$true # Save my password securely and auto-login after a reboot
# Basic setup
Update-ExecutionPolicy Unrestricted
@michaelkc
michaelkc / EnableRemoteDesktop.ps1
Last active June 29, 2016 13:38
EnableRemoteDesktop.ps1
# wget tinyurl.com/enablerdp -outfile .\rdp.ps1
# .\rdp.ps1
set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server'-name "fDenyTSConnections" -Value 0
Enable-NetFirewallRule -DisplayGroup "Remote Desktop"
set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "UserAuthentication" -Value 1
@michaelkc
michaelkc / ensureWHS.ps1
Last active August 29, 2015 14:14
Creating web hosting plan and ensuring websites and staging slots all use it
Import-Module Azure
Set-StrictMode -version 4
$location = "North Europe"
$resourceGroupName = 'Default-Web-' + $location.Replace(' ', '');
$webHostingPlanName = "StandardSmall";
$websiteResourceType = "Microsoft.Web/sites";
$stagingSlotResourceType = "Microsoft.Web/sites/slots";
function New-AzureWebHostingPlan($hostingPlanName)
{
<?xml version="1.0" encoding="utf-8"?>
<PortableRelyingParty xmlns="http://schemas.datacontract.org/2004/07/Dlbr.CommonLogin.AdfsSnapIn" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<AutoUpdateEnabled>false</AutoUpdateEnabled>
<ClaimsAccepted />
<ConflictWithPublishedPolicy>false</ConflictWithPublishedPolicy>
<DelegationAuthorizationRules />
<Enabled>true</Enabled>
<EncryptClaims>true</EncryptClaims>
<EncryptedNameIdRequired>false</EncryptedNameIdRequired>
<EncryptionCertificateRevocationCheck>CheckChainExcludeRoot</EncryptionCertificateRevocationCheck>
using System;
using System.Configuration;
using System.IdentityModel.Tokens;
using System.Net.Http;
using System.Security.Claims;
using System.Threading.Tasks;
using Dlbr.CommonLogin.Owin;
using Microsoft.IdentityModel.Extensions;
using Microsoft.IdentityModel.Protocols;
using Microsoft.Owin.Logging;
import sublime, sublime_plugin, random, string, os
class saveunnamedbuffersCommand(sublime_plugin.TextCommand):
def run(self, edit):
print("Init")
for window in sublime.windows() :
for view in window.views() :
dirty = view.is_dirty()
filename = str(view.file_name())
print(str(dirty) + " " + filename)