ansible-collections / microsoft.ad

Ansible collection for Active Directory management
GNU General Public License v3.0
41 stars 24 forks source link

error in object_info Unable to find type [Microsoft.ActiveDirectory.Management.ADIdentityNotFoundException]. #70

Closed ghost closed 1 year ago

ghost commented 1 year ago
SUMMARY

When I execute this task:

    - name: Find user samaccountname
      microsoft.ad.object_info:
        domain_server: denverco.gov
        domain_password: "{{ Upass }}"
        domain_username: "{{ Uname }}"
        filter: UserPrincipalName -eq "hailaeos.troy@denvergov.org"
        properties:
          - samaccountname
      delegate_to:  "{{ jumpserver }}"
      register: user_ad_info
      become: true

I get this error: ` The full traceback is: Unable to find type [Microsoft.ActiveDirectory.Management.ADIdentityNotFoundException]. At line:239 char:22

ScriptStackTrace: at , : line 239 fatal: [localhost -> ansapp004p.denverco.gov]: FAILED! => { "changed": false, "msg": "Unhandled exception while executing module: Unable to find type [Microsoft.ActiveDirectory.Management.ADIdentityNotFoundException]." } ` This is on a windows 2019 server with the ActiveDirectory module installed If I run this on a windows 2022 server everything works as expected. Both are have dot net 4.8 installed powershell 5

ISSUE TYPE
COMPONENT NAME

microsoft/ad/plugins/modules/object_info.ps1

ANSIBLE VERSION
 ansible --version
ansible [core 2.15.3]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.9.16 (main, May 31 2023, 12:21:58) [GCC 8.5.0 20210514 (Red Hat 8.5.0-18)] (/usr/bin/python3.9)
  jinja version = 3.1.2
  libyaml = True
COLLECTION VERSION
1.3.0
CONFIGURATION
OS / ENVIRONMENT
STEPS TO REPRODUCE

see summary

    - name: Find user samaccountname
      microsoft.ad.object_info:
        domain_server: denverco.gov
        domain_password: "{{ Upass }}"
        domain_username: "{{ Uname }}"
        filter: UserPrincipalName -eq "hailaeos.troy@denvergov.org"
        properties:
          - samaccountname
      delegate_to:  "{{ jumpserver }}"
      register: user_ad_info
      become: true
EXPECTED RESULTS

TASK [show results] ** ok: [localhost] => { "msg": [ { "changed": false, "failed": false, "objects": [ { "DistinguishedName": "CN=Troy........", "Name": "Troy, Holly -......", "ObjectClass": "user", "ObjectGUID": "44118295-......7e3a24c53d9", "samaccountname": "20....." } ] } ] }

ACTUAL RESULTS

TASK [Find user samaccountname] ** An exception occurred during task execution. To see the full traceback, use -vvv. The error was: at , : line 239 fatal: [localhost -> ansapp004p.denverco.gov]: FAILED! => {"changed": false, "msg": "Unhandled exception while executing module: Unable to find type [Microsoft.ActiveDirectory.Management.ADIdentityNotFoundException]."}

ghost commented 1 year ago

Turns out the powershell module Pscx https://www.powershellgallery.com/packages/Pscx/3.3.2 was the culprit removed it and things work.