Skip to content

Commit

Permalink
Fix up missing common AD parameters on some cmdlets
Browse files Browse the repository at this point in the history
  • Loading branch information
jborean93 committed Aug 7, 2023
1 parent 6bf01b5 commit 7fe2f4d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions changelogs/fragments/move-adparams.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
bugfixes:
- >-
Ensure renaming and moving an object will be done with the ``domain_server`` and ``domain_username`` credentials
specified - https://github.com/ansible-collections/microsoft.ad/issues/54
6 changes: 3 additions & 3 deletions plugins/module_utils/_ADObject.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ Function Invoke-AnsibleADObject {

# Remove-ADObject -Recursive fails with access is denied, use this
# instead to remove the child objects manually
Get-ADObject -Filter * -Properties ProtectedFromAccidentalDeletion -Searchbase $adObject.DistinguishedName |
Get-ADObject -Filter * -Properties ProtectedFromAccidentalDeletion -Searchbase $adObject.DistinguishedName @adParams |
Sort-Object -Property { $_.DistinguishedName.Length } -Descending |
ForEach-Object -Process {
if ($_.ProtectedFromAccidentalDeletion) {
Expand Down Expand Up @@ -1077,7 +1077,7 @@ Function Invoke-AnsibleADObject {
$objectName = $module.Params.name
$module.Diff.after.name = $objectName

$finalADObject = Rename-ADObject @commonParams -NewName $objectName
$finalADObject = Rename-ADObject @commonParams @adParams -NewName $objectName
$module.Result.changed = $true
}

Expand All @@ -1092,7 +1092,7 @@ Function Invoke-AnsibleADObject {
}

try {
$finalADObject = Move-ADObject @commonParams -TargetPath $objectPath
$finalADObject = Move-ADObject @commonParams @adParams -TargetPath $objectPath
}
finally {
if ($addProtection) {
Expand Down

0 comments on commit 7fe2f4d

Please sign in to comment.