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 2, 2019
1 parent 3efea91 commit e430158
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 @@ -87,6 +87,8 @@
- Now it correctly tests passwords when parameter DomainName is set to
distinguished name and parameter Credential is used ([issue #451](https://github.com/PowerShell/ActiveDirectoryDsc/issues/451)).
- Added integration tests ([issue #359](https://github.com/PowerShell/ActiveDirectoryDsc/issues/359)).
- 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 @@ -2350,7 +2350,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 @@ -2370,7 +2372,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 @@ -2379,7 +2381,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 e430158

Please sign in to comment.