Minor validation and perf fixes in password mod.

This commit is contained in:
Michael Grafnetter 2018-09-28 18:40:35 +02:00
parent 047731c67b
commit 38d19bdefb
2 changed files with 11 additions and 5 deletions

View File

@ -44,13 +44,18 @@
// Calculate NT hash
byte[] ntHash = NTHash.ComputeHash(newPassword);
// TODO TODO TODO: Change parameter to DSAccount from DatastoreObject
var account = this.GetAccount(targetObject, targetObjectIdentifier, bootKey);
// We need to read sAMAccountName and userPrincipalName to be able to generate the supplementalCredentials.
string samAccountName;
targetObject.ReadAttribute(CommonDirectoryAttributes.SAMAccountName, out samAccountName);
string userPrincipalName;
targetObject.ReadAttribute(CommonDirectoryAttributes.UserPrincipalName, out userPrincipalName);
var supplementalCredentials = new SupplementalCredentials(
newPassword,
account.SamAccountName,
account.UserPrincipalName,
samAccountName,
userPrincipalName,
this.context.DomainController.NetBIOSDomainName,
this.context.DomainController.Domain);
@ -93,6 +98,7 @@
{
// Validate input
Validator.AssertLength(newNtHash, NTHash.HashSize, "newNtHash");
Validator.AssertNotNull(bootKey, "bootKey");
if (!targetObject.IsAccount)
{

View File

@ -3,7 +3,6 @@ using DSInternals.DataStore;
using DSInternals.PowerShell.Properties;
using System;
using System.Management.Automation;
using System.Security;
namespace DSInternals.PowerShell.Commands
{
@ -24,6 +23,7 @@ namespace DSInternals.PowerShell.Commands
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true)]
[Alias("KerberosKeys", "sc", "c")]
[ValidateNotNull]
public SupplementalCredentials SupplementalCredentials
{
get;