Hello, I’m attempting an LDAP search using an Ansible playbook to list the usernames. Unfortunately, it’s not working as expected. Does anyone have any tips or insights regarding this?
My playbook:
---
- name: Query AD for User List
hosts: localhost
vars:
ansible_python_interpreter: /usr/bin/python3
tasks:
- name: Query AD for users
community.general.ldap_search:
server_uri: ldap://domain.xy:389
dn: "OU=Mitarbeiter,OU=PM,DC=domain,DC=xy"
bind_dn: "CN=SU_PM_AWX,OU=PM,DC=domain,DC=xy"
bind_pw: "xyz"
filter: "(objectClass=user)"
#validate_certs: no
#attrs:
#- "sAMAccountName"
register: ad_users
- name: Display AD Users
debug:
var: ad_users
Output:
PLAY [Query AD for User List] ************************************************************************************************************************************************************************************************************************************************
TASK [Gathering Facts] *******************************************************************************************************************************************************************************************************************************************************
ok: [localhost]
TASK [Query AD for users] ****************************************************************************************************************************************************************************************************************************************************
ok: [localhost]
TASK [Display AD Users] ******************************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
"ad_users": {
"changed": false,
"failed": false,
"results": []
}
}
PLAY RECAP *******************************************************************************************************************************************************************************************************************************************************************
localhost : ok=3 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0