Closed murrahjm closed 1 month ago
Thanks for the bug report, I'll have to find a way to set these bitlocker keys for testing. Appreciate the excellent information you've provided that covers this issue.
I've tried testing this out by creating a mock bitlocker key object to a dummy computer object and it works fine.
- name: create computer object
microsoft.ad.computer:
name: TestComputer
state: present
register: create_comp
- name: add recovery leaf object
ansible.windows.win_powershell:
parameters:
Path: '{{ create_comp.distinguished_name }}'
script: |
param([string]$Path)
$ErrorActionPreference = 'Stop'
$keyGuid = [Guid]::NewGuid()
$recoveryParams = @{
Name = "$((Get-Date).ToString('yyyy-MM-ddThh:mm:sszzz')){$($keyGuid.ToString().ToUpperInvariant())}"
Path = $Path
Type = 'msFVE-RecoveryInformation'
OtherAttributes = @{
'msFVE-RecoveryGuid' = $keyGuid.ToByteArray()
'msFVE-RecoveryPassword' = '1234'
}
}
New-ADObject @recoveryParams
- name: remove computer
microsoft.ad.computer:
name: TestComputer
state: absent
The error you are receiving somewhat indicates to me that the object might be potentially malformed. If you open up the attribute editor for the key object do you see top
in objectClass
?
Note: I had to do View
-> User, Contacts, Groups, and Computers as containers
to see it.
ok I think this might be a permissions issue. When I check the objects I see no objectclass at all. but I went and had our domain admins check it and they look right to him.
I'm going to do some tests with different permissions and will report back.
hey sorry for the delay, but I can confirm that this was an issue with my permissions. I had full control of the objects only, and nothing to the child objects, which is why I couldn't read the objectClass or any other property.
No worries, thanks for confirming and sharing the info.
SUMMARY
When trying to delete a computer account with the
microsoft.ad.computer
module and it has leaf objects (bitlocker keys I think), it fails with the errorRemove-ADObject: The object class of the instance object must contain 'top'.
This is reproduceable in native powershell when trying to delete the leaf objects, not the computer object itself.ISSUE TYPE
COMPONENT NAME
microsoft.ad.computer
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
Windows Server 2019 Standard
STEPS TO REPRODUCE
Create a playbook that attempts to delete a computer object with bitlocker keys.
EXPECTED RESULTS
Expected results would be for the computer account to be deleted
ACTUAL RESULTS
Task fails with a stack trace:
This appears to be an issue with this line: https://github.com/ansible-collections/microsoft.ad/blob/b8a7a231d4e82fac8e385dc8bf3c3a3fded3c243/plugins/module_utils/_ADObject.psm1#L1170
Reproducing this in powershell shows that this is an issue with bitlocker leaf objects:
Note that in powershell, specifying the identity parameter instead of using the pipeline seems to work: