Skip to content

Commit

Permalink
Don't assume UserName is SamAccountName
Browse files Browse the repository at this point in the history
Fix New-ADUser to use '-Name' instead of '-SamAccountName' for specifying the user account name. Change parameter descriptions to clarify that UserName can be more than just SamAccountName.
  • Loading branch information
gaelicWizard committed May 17, 2021
1 parent a385d84 commit cb91a2a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions source/DSCResources/MSFT_ADUser/MSFT_ADUser.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ $adPropertyMap = (Import-PowerShellDataFile -Path $adPropertyMapPath).Parameters
Name of the domain where the user account is located (only used if password is managed).
.PARAMETER UserName
Specifies the Security Account Manager (SAM) account name of the user (ldapDisplayName 'sAMAccountName').
Specifies the account name of the user. (You can identify a user by its distinguished
name (DN), GUID, security identifier (SID) or Security Accounts Manager (SAM) account name.)
.PARAMETER DomainController
Specifies the Active Directory Domain Services instance to use to perform the task.
Expand Down Expand Up @@ -185,7 +186,8 @@ function Get-TargetResource
Name of the domain where the user account is located (only used if password is managed).
.PARAMETER UserName
Specifies the Security Account Manager (SAM) account name of the user (ldapDisplayName 'sAMAccountName').
Specifies the account name of the user. (You can identify a user by its distinguished
name (DN), GUID, security identifier (SID) or Security Accounts Manager (SAM) account name.)
.PARAMETER Password
Specifies a new password value for the account.
Expand Down Expand Up @@ -869,7 +871,8 @@ function Test-TargetResource
Name of the domain where the user account is located (only used if password is managed).
.PARAMETER UserName
Specifies the Security Account Manager (SAM) account name of the user (ldapDisplayName 'sAMAccountName').
Specifies the account name of the user. (You can identify a user by its distinguished
name (DN), GUID, security identifier (SID) or Security Accounts Manager (SAM) account name.)
.PARAMETER Password
Specifies a new password value for the account.
Expand Down Expand Up @@ -1506,7 +1509,7 @@ function Set-TargetResource

Write-Debug -Message ('New-ADUser Parameters:' + ($newADUserParams | Out-String))

$newADUser = New-ADUser @newADUserParams -SamAccountName $UserName -Passthru
$newADUser = New-ADUser @newADUserParams -Name $UserName -Passthru

if ($updateCnRequired)
{
Expand Down

0 comments on commit cb91a2a

Please sign in to comment.