Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADUser: Uses helper function Add-TypeAssembly #458

Merged
merged 1 commit into from
Aug 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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