Skip to main content

Posts

Showing posts from March, 2020

Azure AD error - 'IDX10311: RequireNonce is true but validationContext.Nonce is null'

I've experienced this one enough times now that I'd like to preserve the solution/s for future occurrences. The exact message is:
IDX10311: RequireNonce is 'true' (default) but validationContext.Nonce is null. A nonce cannot be validated. If you don't need to check the nonce, set OpenIdConnectProtocolValidator.RequireNonce to 'false'. An easy way to reproduce this one is to hit the "back" button after having signed in to an ASP.NET web app that auths with Azure AD using the OWIN library.

https://stackoverflow.com/questions/29502788/enabling-ssl-in-asp-net-mvc-5-app-results-in-openidconnectprotocolvalidator-issu

Export every field of every record of a bunch of Salesforce objects

I needed to get a backup of every record of a bunch of objects (for posterity) which were about to be deleted, I wanted to grab every field and do it in one line. I cheated a little, because I've defined some functions that just do some of the basic processing. I could put the whole function definitions on one line too, but that'd be a bit contrived ;) They're below for reference



('object_name_1__c','object_name_2__c') | foreach-object { $fields = (sffields $_) -join ',' $query = "select $fields from $_" sfquery $query | export-csv "$_.csv" -NoTypeInformation -Encoding ASCII } function SFFields { (force describe -n="$($args[0])" -t=sobject | ConvertFrom-Json).Fields | Sort-Object name | Select-Object -ExpandProperty name } function SFQuery { force query --format json $args[0] | ConvertFrom-Json }

Combine many CSVs into batches of a specified size with Powershell

$batchMaxSize = 9.5MB $allFiles = Get-ChildItem 'fileLocation\*.csv' $batchNumber = 0; $batchMagnitude = $allFiles.Count.ToString().Length # group the files together until there's none left while ($allFiles.Count -gt 0) { $batchNumber++; $batchSuffix = $batchNumber.ToString().PadLeft($batchMagnitude,"0"); $totalSize = 0; # add the file sizes together, keeping a running total until it exceeds the max $batchFiles = $allFiles | where {$totalSize += $_.Length; $totalSize -lt $batchMaxSize}; # combine the files in memory - don't need to deal with headers # this step could cause memory issues with extremely large files # but then you probably wouldn't be batching them ;) $comboFile = $batchFiles | Foreach-Object { Import-Csv -Path $_; } $comboFile | Export-Csv "batched\batch-$batchSuffix.csv" -Encoding ASCII -NoTypeInformation # removes the files we just batched together from the list of all…