Skip to content

Commit

Permalink
Changes to ADUser
Browse files Browse the repository at this point in the history
- Now uses the helper function `Add-TypeAssembly` which have some benefit
  instead of directly using `Add-Type`, like verbose logging (issue dsccommunity#431).
  • Loading branch information
johlju committed Aug 3, 2019
1 parent 3a4b75f commit fe4a3a3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@
- Update the logic for setting the default value for the parameter
`CommonName`. This is due to an how LCM handles parameters when a
default value is derived from another parameter ([issue #427](https://github.com/PowerShell/ActiveDirectoryDsc/issues/427)).
- Now uses the helper function `Add-TypeAssembly` which have some benefit
instead of directly using `Add-Type`, like verbose logging ([issue #431](https://github.com/PowerShell/ActiveDirectoryDsc/issues/431)).
- Changes to ADDomain
- BREAKING CHANGE: Renamed the parameter `DomainAdministratorCredential`
to `Credential` to better indicate that it is possible to impersonate
Expand Down
8 changes: 5 additions & 3 deletions DSCResources/MSFT_ADUser/MSFT_ADUser.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -2377,7 +2377,9 @@ function Test-Password

Write-Verbose -Message ($script:localizedData.CreatingADDomainConnection -f $DomainName)

Add-Type -AssemblyName 'System.DirectoryServices.AccountManagement'
$typeName = 'System.DirectoryServices.AccountManagement.PrincipalContext'

Add-TypeAssembly -AssemblyName 'System.DirectoryServices.AccountManagement' -TypeName $typeName

<#
If the domain name contains a distinguished name, set it to the fully
Expand All @@ -2397,7 +2399,7 @@ function Test-Password
$script:localizedData.TestPasswordUsingImpersonation -f $Credential.UserName, $UserName
)

$principalContext = New-Object -TypeName 'System.DirectoryServices.AccountManagement.PrincipalContext' -ArgumentList @(
$principalContext = New-Object -TypeName $typeName -ArgumentList @(
[System.DirectoryServices.AccountManagement.ContextType]::Domain,
$DomainName,
$Credential.UserName,
Expand All @@ -2406,7 +2408,7 @@ function Test-Password
}
else
{
$principalContext = New-Object -TypeName 'System.DirectoryServices.AccountManagement.PrincipalContext' -ArgumentList @(
$principalContext = New-Object -TypeName $typeName -ArgumentList @(
[System.DirectoryServices.AccountManagement.ContextType]::Domain,
$DomainName,
$null,
Expand Down

0 comments on commit fe4a3a3

Please sign in to comment.