From 38956fb1010007c700b225ecd4c5e15ab33e42ac Mon Sep 17 00:00:00 2001 From: BlueCurby Date: Mon, 7 Aug 2023 21:02:35 +0200 Subject: [PATCH] Add Test-PasswordQuality SamAccountName Test; Code enhancement --- .../Commands/Misc/TestPasswordQualityCommand.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Src/DSInternals.PowerShell/Commands/Misc/TestPasswordQualityCommand.cs b/Src/DSInternals.PowerShell/Commands/Misc/TestPasswordQualityCommand.cs index 990b156..e457a94 100644 --- a/Src/DSInternals.PowerShell/Commands/Misc/TestPasswordQualityCommand.cs +++ b/Src/DSInternals.PowerShell/Commands/Misc/TestPasswordQualityCommand.cs @@ -473,19 +473,21 @@ private void TestSamAccountNameAsPassword() { string userLowerPassword = this.Account.SamAccountName.ToLower(); - string userExactPassword = this.Account.SamAccountName; + byte[] userLowerHash = NTHash.ComputeHash(userLowerPassword); - byte[] userExactHash = NTHash.ComputeHash(userExactPassword); + if (HashEqualityComparer.GetInstance().Equals(this.Account.NTHash, userLowerHash)) { // Username Password is lowercase SamAccountName - this.result.SamAccountNameAsPassword.Add(this.Account.LogonName); } else { + string userExactPassword = this.Account.SamAccountName; + byte[] userExactHash = NTHash.ComputeHash(userExactPassword); if (HashEqualityComparer.GetInstance().Equals(this.Account.NTHash, userExactHash)) { + // Username Password is exact SamAccountName this.result.SamAccountNameAsPassword.Add(this.Account.LogonName); }