mirror of
https://github.com/MichaelGrafnetter/DSInternals
synced 2025-01-05 21:49:47 +00:00
Added test generation code for #34
This commit is contained in:
parent
6e332307e9
commit
99cba912f2
@ -167,6 +167,7 @@
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
<None Include="Tests\ConvertTo-OrgIdHashNative.ps1" />
|
||||
<None Include="Tests\Set-SamAccountPasswordHash.Tests.ps1" />
|
||||
<None Include="Tests\Path.Tests.ps1" />
|
||||
<None Include="Tests\ConvertFrom-UnicodePassword.Tests.ps1" />
|
||||
|
@ -0,0 +1,20 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Calculates the OrgId hash of a given password using Azure AD Connect's library.
|
||||
.DESCRIPTION
|
||||
This is only used to manually generate test data for C# Unit Tests.
|
||||
#>
|
||||
#Requires -Module DSInternals
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[SecureString] $Password
|
||||
)
|
||||
|
||||
## Load the Microsoft.Online.PasswordSynchronization.Cryptography.dll assembly from Azure AD Connect
|
||||
# Location is typically 'C:\Program Files\Microsoft Azure AD Sync\', but it can be changed during installation.
|
||||
$adSyncPath = (Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\AD Sync').Location
|
||||
$cryptoAssemblyPath = Join-Path $adSyncPath 'Bin\Microsoft.Online.PasswordSynchronization.Cryptography.dll'
|
||||
Add-Type -Path $cryptoAssemblyPath -ErrorAction Stop
|
||||
|
||||
$ntHash = ConvertTo-NTHash -Password $Password
|
||||
return [Microsoft.Online.PasswordSynchronization.OrgIdHashGenerator]::Generate($ntHash.ToUpper())
|
Loading…
Reference in New Issue
Block a user